Re: [libcxx] r249738 - Split out of .

2016-07-27 Thread Nico Weber via cfe-commits
I played with modules a bit today, and as far as I can tell this is still
broken. If this proves difficult to fix, should this change be reverted for
now? It breaks using modules on Darwin.

On Sun, Mar 13, 2016 at 12:53 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> > On Mar 11, 2016, at 4:11 PM, Duncan P. N. Exon Smith <
> dexonsm...@apple.com> wrote:
> >
> > Did anyone file a PR for this?
> >
>
> I filed PR 26928 - Prune the include path for modules
> https://llvm.org/bugs/show_bug.cgi?id=26928
> as a starting point.
>
> -- adrian
>
> ___
> 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


Re: [PATCH] D22810: scan-build: Add an option to show the description in the list of defect

2016-07-27 Thread Sylvestre Ledru via cfe-commits
sylvestre.ledru added a comment.

The Firefox report is using a previous version of the patch (which could not be 
merged upstream: quick and dirty).
If you want, I can update my scan-build instance to use the new version (which 
doesn't have the issues you mentioned)


https://reviews.llvm.org/D22810



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


Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-07-27 Thread Honggyu Kim via cfe-commits
honggyu.kim updated this revision to Diff 65879.
honggyu.kim added a comment.

I've updated the diff that can be working with https://reviews.llvm.org/D22825. 
 I appreciate your work in backend, Hal.
Please correct me if I'm wrong.


https://reviews.llvm.org/D22666

Files:
  lib/CodeGen/CodeGenFunction.cpp

Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -428,14 +428,6 @@
   EmitNounwindRuntimeCall(F, args);
 }
 
-void CodeGenFunction::EmitMCountInstrumentation() {
-  llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
-
-  llvm::Constant *MCountFn =
-CGM.CreateRuntimeFunction(FTy, getTarget().getMCountName());
-  EmitNounwindRuntimeCall(MCountFn);
-}
-
 // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
 // information in the program executable. The argument information stored
 // includes the argument name, its type, the address and access qualifiers 
used.
@@ -794,8 +786,12 @@
   if (ShouldInstrumentFunction())
 EmitFunctionInstrumentation("__cyg_profile_func_enter");
 
+  // Since emitting mcount call here impacts optimization phase such as 
function
+  // inlining, we just mark an attribute to insert a mcount call in backend.
+  // Attribute "counting-function" is set to mcount function name which is
+  // architecture dependent, and it is processed by CountingFunctionInserter.
   if (CGM.getCodeGenOpts().InstrumentForProfiling)
-EmitMCountInstrumentation();
+Fn->addFnAttr("counting-function", getTarget().getMCountName());
 
   if (RetTy->isVoidType()) {
 // Void type; nothing to return.


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -428,14 +428,6 @@
   EmitNounwindRuntimeCall(F, args);
 }
 
-void CodeGenFunction::EmitMCountInstrumentation() {
-  llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
-
-  llvm::Constant *MCountFn =
-CGM.CreateRuntimeFunction(FTy, getTarget().getMCountName());
-  EmitNounwindRuntimeCall(MCountFn);
-}
-
 // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
 // information in the program executable. The argument information stored
 // includes the argument name, its type, the address and access qualifiers used.
@@ -794,8 +786,12 @@
   if (ShouldInstrumentFunction())
 EmitFunctionInstrumentation("__cyg_profile_func_enter");
 
+  // Since emitting mcount call here impacts optimization phase such as function
+  // inlining, we just mark an attribute to insert a mcount call in backend.
+  // Attribute "counting-function" is set to mcount function name which is
+  // architecture dependent, and it is processed by CountingFunctionInserter.
   if (CGM.getCodeGenOpts().InstrumentForProfiling)
-EmitMCountInstrumentation();
+Fn->addFnAttr("counting-function", getTarget().getMCountName());
 
   if (RetTy->isVoidType()) {
 // Void type; nothing to return.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r276958 - [AArch64] Using AArch64TargetParser in Clang.

2016-07-27 Thread Zijiao Ma via cfe-commits
Author: zijiaoma
Date: Thu Jul 28 01:24:48 2016
New Revision: 276958

URL: http://llvm.org/viewvc/llvm-project?rev=276958&view=rev
Log:
[AArch64] Using AArch64TargetParser in Clang.

This resubmit r270688 which broke some specific buildbots.That's because
there is incorrect indexing problem in the targetparser,and the problem is
fixed in r276957.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=276958&r1=276957&r2=276958&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jul 28 01:24:48 2016
@@ -5726,19 +5726,9 @@ public:
   }
 
   bool setCPU(const std::string &Name) override {
-bool CPUKnown = llvm::StringSwitch(Name)
-  .Case("cortex-a35", true)
-  .Case("cortex-a53", true)
-  .Case("cortex-a57", true)
-  .Case("cortex-a72", true)
-  .Case("cortex-a73", true)
-  .Case("cyclone", true)
-  .Case("exynos-m1", true)
-  .Case("generic", true)
-  .Case("kryo", true)
-  .Case("vulcan", true)
-  .Default(false);
-return CPUKnown;
+return Name == "generic" ||
+   llvm::AArch64::parseCPUArch(Name) !=
+   static_cast(llvm::AArch64::ArchKind::AK_INVALID);
   }
 
   void getTargetDefines(const LangOptions &Opts,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276958&r1=276957&r2=276958&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jul 28 01:24:48 2016
@@ -2340,24 +2340,8 @@ static bool DecodeAArch64Features(const
   text.split(Split, StringRef("+"), -1, false);
 
   for (StringRef Feature : Split) {
-const char *result = llvm::StringSwitch(Feature)
- .Case("fp", "+fp-armv8")
- .Case("simd", "+neon")
- .Case("crc", "+crc")
- .Case("crypto", "+crypto")
- .Case("fp16", "+fullfp16")
- .Case("profile", "+spe")
- .Case("ras", "+ras")
- .Case("nofp", "-fp-armv8")
- .Case("nosimd", "-neon")
- .Case("nocrc", "-crc")
- .Case("nocrypto", "-crypto")
- .Case("nofp16", "-fullfp16")
- .Case("noprofile", "-spe")
- .Case("noras", "-ras")
- .Default(nullptr);
-if (result)
-  Features.push_back(result);
+if (const char *FeatureName = llvm::AArch64::getArchExtFeature(Feature))
+  Features.push_back(FeatureName);
 else if (Feature == "neon" || Feature == "noneon")
   D.Diag(diag::err_drv_no_neon_modifier);
 else
@@ -2372,20 +2356,16 @@ static bool DecodeAArch64Mcpu(const Driv
   std::vector &Features) {
   std::pair Split = Mcpu.split("+");
   CPU = Split.first;
-  if (CPU == "cortex-a53" || CPU == "cortex-a57" ||
-  CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1" ||
-  CPU == "kryo"   || CPU == "cortex-a73" || CPU == "vulcan") {
-Features.push_back("+neon");
-Features.push_back("+crc");
-Features.push_back("+crypto");
-  } else if (CPU == "cyclone") {
-Features.push_back("+neon");
-Features.push_back("+crypto");
-  } else if (CPU == "generic") {
+
+  if (CPU == "generic") {
 Features.push_back("+neon");
   } else {
-return false;
-  }
+unsigned ArchKind = llvm::AArch64::parseCPUArch(CPU);
+unsigned Extersion = llvm::AArch64::getDefaultExtensions(CPU, ArchKind);
+
+if (!llvm::AArch64::getExtensionFeatures(Extersion, Features))
+  return false;
+   }
 
   if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
 return false;
@@ -2400,17 +2380,10 @@ getAArch64ArchFeaturesFromMarch(const Dr
   std::string MarchLowerCase = March.lower();
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
-  if (Split.first == "armv8-a" || Split.first == "armv8a") {
-// ok, no additional features.
-  } else if (Split.first == "armv8.1-a" || Split.first == "armv8.1a") {
-Features.push_back("+v8.1a");
-  } else if (Split.first == "armv8.2-a" || Split.first == "armv8.2a" ) {
-Features.push_back("+v8.2a");
-  } else {
-return false;
-  }
-
-  if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
+  unsigned ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (ArchKind == static_cast(llvm::AArch64::ArchKind::AK_INVALID) ||
+  !llvm::AArch64::ge

Re: [PATCH] D21277: Resubmit r270688: Using new TargetParser in Clang.

2016-07-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276958: [AArch64] Using AArch64TargetParser in Clang. 
(authored by zijiaoma).

Changed prior to commit:
  https://reviews.llvm.org/D21277?vs=60658&id=65878#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21277

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -5726,19 +5726,9 @@
   }
 
   bool setCPU(const std::string &Name) override {
-bool CPUKnown = llvm::StringSwitch(Name)
-  .Case("cortex-a35", true)
-  .Case("cortex-a53", true)
-  .Case("cortex-a57", true)
-  .Case("cortex-a72", true)
-  .Case("cortex-a73", true)
-  .Case("cyclone", true)
-  .Case("exynos-m1", true)
-  .Case("generic", true)
-  .Case("kryo", true)
-  .Case("vulcan", true)
-  .Default(false);
-return CPUKnown;
+return Name == "generic" ||
+   llvm::AArch64::parseCPUArch(Name) !=
+   static_cast(llvm::AArch64::ArchKind::AK_INVALID);
   }
 
   void getTargetDefines(const LangOptions &Opts,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -2340,24 +2340,8 @@
   text.split(Split, StringRef("+"), -1, false);
 
   for (StringRef Feature : Split) {
-const char *result = llvm::StringSwitch(Feature)
- .Case("fp", "+fp-armv8")
- .Case("simd", "+neon")
- .Case("crc", "+crc")
- .Case("crypto", "+crypto")
- .Case("fp16", "+fullfp16")
- .Case("profile", "+spe")
- .Case("ras", "+ras")
- .Case("nofp", "-fp-armv8")
- .Case("nosimd", "-neon")
- .Case("nocrc", "-crc")
- .Case("nocrypto", "-crypto")
- .Case("nofp16", "-fullfp16")
- .Case("noprofile", "-spe")
- .Case("noras", "-ras")
- .Default(nullptr);
-if (result)
-  Features.push_back(result);
+if (const char *FeatureName = llvm::AArch64::getArchExtFeature(Feature))
+  Features.push_back(FeatureName);
 else if (Feature == "neon" || Feature == "noneon")
   D.Diag(diag::err_drv_no_neon_modifier);
 else
@@ -2372,20 +2356,16 @@
   std::vector &Features) {
   std::pair Split = Mcpu.split("+");
   CPU = Split.first;
-  if (CPU == "cortex-a53" || CPU == "cortex-a57" ||
-  CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1" ||
-  CPU == "kryo"   || CPU == "cortex-a73" || CPU == "vulcan") {
-Features.push_back("+neon");
-Features.push_back("+crc");
-Features.push_back("+crypto");
-  } else if (CPU == "cyclone") {
-Features.push_back("+neon");
-Features.push_back("+crypto");
-  } else if (CPU == "generic") {
+
+  if (CPU == "generic") {
 Features.push_back("+neon");
   } else {
-return false;
-  }
+unsigned ArchKind = llvm::AArch64::parseCPUArch(CPU);
+unsigned Extersion = llvm::AArch64::getDefaultExtensions(CPU, ArchKind);
+
+if (!llvm::AArch64::getExtensionFeatures(Extersion, Features))
+  return false;
+   }
 
   if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
 return false;
@@ -2400,17 +2380,10 @@
   std::string MarchLowerCase = March.lower();
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
-  if (Split.first == "armv8-a" || Split.first == "armv8a") {
-// ok, no additional features.
-  } else if (Split.first == "armv8.1-a" || Split.first == "armv8.1a") {
-Features.push_back("+v8.1a");
-  } else if (Split.first == "armv8.2-a" || Split.first == "armv8.2a" ) {
-Features.push_back("+v8.2a");
-  } else {
-return false;
-  }
-
-  if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
+  unsigned ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (ArchKind == static_cast(llvm::AArch64::ArchKind::AK_INVALID) ||
+  !llvm::AArch64::getArchFeatures(ArchKind, Features) ||
+  (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features)))
 return false;
 
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22566: Make RecursiveASTVisitor visit lambda capture initialization expressions

2016-07-27 Thread Martin Böhme via cfe-commits
mboehme added a comment.

This was reverted in https://reviews.llvm.org/rL276759 because it broke 
modernize-loop-convert.

https://reviews.llvm.org/D22903 contains a fix for the modernize-loop-convert 
issue. Will re-submit this patch once https://reviews.llvm.org/D22903 has 
landed.


Repository:
  rL LLVM

https://reviews.llvm.org/D22566



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


[PATCH] D22903: [clang-tidy] Prepare modernize-loop-convert for upcoming changes in D22566

2016-07-27 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: klimek.
mboehme added a subscriber: cfe-commits.

D22566 will change RecursiveASTVisitor so that it descends into the 
initialization expressions for lambda captures.

modernize-loop-convert needs to be prepared for this so that it does not 
interpret these initialization expressions as invalid uses of the loop 
variable. The change has no ill effects without D22566 in place, i.e. the 
change does not depend on D22566.

https://reviews.llvm.org/D22903

Files:
  clang-tidy/modernize/LoopConvertUtils.cpp

Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -805,6 +805,18 @@
 }
 
 bool ForLoopIndexUseVisitor::TraverseStmt(Stmt *S) {
+  // If this is an initialization expression for a lambda capture, prune the
+  // traversal so that we don't end up diagnosing the contained DeclRefExpr as
+  // inconsistent usage. No need to record the usage here -- this is done in
+  // TraverseLambdaCapture().
+  if (const auto *LE = dyn_cast_or_null(NextStmtParent)) {
+// Any child of a LambdaExpr that isn't the body is an initialization
+// expression.
+if (S != LE->getBody()) {
+  return true;
+}
+  }
+
   // All this pointer swapping is a mechanism for tracking immediate parentage
   // of Stmts.
   const Stmt *OldNextParent = NextStmtParent;


Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -805,6 +805,18 @@
 }
 
 bool ForLoopIndexUseVisitor::TraverseStmt(Stmt *S) {
+  // If this is an initialization expression for a lambda capture, prune the
+  // traversal so that we don't end up diagnosing the contained DeclRefExpr as
+  // inconsistent usage. No need to record the usage here -- this is done in
+  // TraverseLambdaCapture().
+  if (const auto *LE = dyn_cast_or_null(NextStmtParent)) {
+// Any child of a LambdaExpr that isn't the body is an initialization
+// expression.
+if (S != LE->getBody()) {
+  return true;
+}
+  }
+
   // All this pointer swapping is a mechanism for tracking immediate parentage
   // of Stmts.
   const Stmt *OldNextParent = NextStmtParent;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r276949 and resolved a failing test 
(FunctionWithClassFindByName.cpp).


https://reviews.llvm.org/D21814



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


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65876.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 void foo() {
 }
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/c

Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo abandoned this revision.
mstorsjo added a comment.

This test isn't strictly necessary, thus abandoning


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/diagnostics/Inputs/include/Something.h:1
@@ +1,2 @@
+void clang_analyzer_warnIfReached();
+

Please, choose better file names. Every test that adds something cannot add a 
header called something:) It won't scale.


Comment at: test/Analysis/diagnostics/plist-diagnostics-include-check.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection 
-analyzer-output=plist-multi-file -o plist.xml %s
+

Please, check that output is produced. Search for other tests with 
-analyzer-poutput=plist-multi-file for examples.


https://reviews.llvm.org/D22090



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

We'd definitely want the same routine in both: printing the name in 
-analyzer-display-progress and be accepted by -analyze-function.

Looks like what ND->getQualifiedNameAsString() returns is not proper ObjC 
syntax, but maybe it's fine for the debug feature? Even though it is not very 
readable...


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22862: [analyzer] Fix for PR15623: eliminate unwanted ProgramState checker data propagation.

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

I am not sure it's the right way of fixing this problem and it introduces a 
regression. The bug is probably specific to "&&".

+ Devin as we might have seen something similar.



Comment at: test/Analysis/misc-ps-region-store.m:332
@@ -330,3 +331,3 @@
   if (p < q) {
 // If we reach here, 'p' cannot be null.  If 'p' is null, then 'n' must
 // be '0', meaning that this branch is not feasible.

Try substituting 'p' with null and you will se that n must be zero in that case 
because, otherwise, we would take the early return branch. Since p is not null, 
we should not warn here. 

This is a regression.


https://reviews.llvm.org/D22862



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


[libcxx] r276955 - Add a bunch of noexcepts to char_traits and string_view.

2016-07-27 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Jul 27 23:52:02 2016
New Revision: 276955

URL: http://llvm.org/viewvc/llvm-project?rev=276955&view=rev
Log:
Add a bunch of noexcepts to char_traits and string_view.

Modified:
libcxx/trunk/include/__string
libcxx/trunk/include/string_view

Modified: libcxx/trunk/include/__string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__string?rev=276955&r1=276954&r2=276955&view=diff
==
--- libcxx/trunk/include/__string (original)
+++ libcxx/trunk/include/__string Wed Jul 27 23:52:02 2016
@@ -207,19 +207,19 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) 
_NOEXCEPT
 {return (unsigned char)__c1 < (unsigned char)__c2;}
 
-static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);}
-static inline size_t length(const char_type* __s) {return strlen(__s);}
-static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a)
+static inline size_t length(const char_type* __s)  _NOEXCEPT {return 
strlen(__s);}
+static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a) _NOEXCEPT
 {return __n == 0 ? NULL : (const char_type*) memchr(__s, 
to_int_type(__a), __n);}
-static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
-static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
 }
-static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
+static inline char_type* assign(char_type* __s, size_t __n, char_type __a) 
_NOEXCEPT
 {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), 
__n);}
 
 static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -252,20 +252,20 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) 
_NOEXCEPT
 {return __c1 < __c2;}
 
-static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline int compare(const char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);}
-static inline size_t length(const char_type* __s)
+static inline size_t length(const char_type* __s) _NOEXCEPT
 {return wcslen(__s);}
-static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a)
+static inline const char_type* find(const char_type* __s, size_t __n, 
const char_type& __a) _NOEXCEPT
 {return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);}
-static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* move(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);}
-static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n)
+static inline char_type* copy(char_type* __s1, const char_type* __s2, 
size_t __n) _NOEXCEPT
 {
 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy 
overlapped range");
 return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n);
 }
-static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
+static inline char_type* assign(char_type* __s, size_t __n, char_type __a) 
_NOEXCEPT
 {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);}
 
 static inline _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
@@ -299,17 +299,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits
 {return __c1 < __c2;}
 
 _LIBCPP_INLINE_VISIBILITY
-static int  compare(const char_type* __s1, const char_type* 
__s2, size_t __n);
+static int  compare(const char_type* __s1, const char_type* 
__s2, size_t __n) _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY
-static size_t   length(const char_type* __s);
+static size_t   length(const char_type* __s) _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY
-static const char_type* find(const char_type* __s, size_t __n, const 
char_type& __a);
+static const char_type* f

Re: [PATCH] D22810: scan-build: Add an option to show the description in the list of defect

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

The report you are referencing does not seem to have "Description" as a column 
name. Also, the titles row is not gray all the way to the right...


https://reviews.llvm.org/D22810



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


Re: [PATCH] D22494: [analyzer] Explain why analyzer report is not generated (fix for PR12421).

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/PR12421.c:11
@@ +10,2 @@
+
+// CHECK: warning: Path diagnostic report is not generated. HTMLDiagnostics 
does not support diagnostics that cross file boundaries.

ayartsev wrote:
> zaks.anna wrote:
> > We should use the name of the diagnostic consumer here - that will only be 
> > legible for the developers working on the attic analyzer core. 
> Done. As for me the name of the diagnostic consumer also makes the warning 
> more clear and helpful for an ordinary user. From the consumer name he can 
> see what report format is talked about and maybe change the scan-build (which 
> setups the '-analyzer-output' frontend option internally) options. Do you 
> still want to remove the consumer name from the warning?
"HTMLDiagnostics" is not a name a user would be familiar with. You should use 
only familiar terms in diagnostics.


Comment at: test/Analysis/PR12421.h:1
@@ +1,2 @@
+static void f() {
+  int *p = 0;

zaks.anna wrote:
> Please. do not use the PR as a file name. Use the purpose of the test instead,
this does not seem to be done.


https://reviews.llvm.org/D22494



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread David Majnemer via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D22900#498793, @Gerolf wrote:

> Nope, I don't see the tail call. Anyway, I'll simplify my test case. Don't 
> worry about it.
>
> clang++ -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.cpp
>
> cat t.ll:
>
> ; ModuleID = 't.cpp'
>  source_filename = "t.cpp"
>  target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
>  target triple = "i386-apple-darwin9"
>
> %struct.C = type { %struct.CBase, %struct.I }
>  %struct.CBase = type { i32 (...)** }
>  %struct.I = type { i32 (...)** }
>  %struct.LARGE = type { %union.anon }
>  %union.anon = type { i32 }
>
> ; Function Attrs: nounwind
>  define void @_ZN1C4SeekE5LARGE(%struct.C* %this, %struct.LARGE* byval align 
> 4) #0 align 2 {
> entry:
>
>   %this.addr = alloca %struct.C*, align 4
>   store %struct.C* %this, %struct.C** %this.addr, align 4
>   %this1 = load %struct.C*, %struct.C** %this.addr, align 4
>   ret void
>
> }
>
> attributes #0 = { nounwind "disable-tail-calls"="false" 
> "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" 
> "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
> "stack-protector-buffer-size"="8" "target-features"="+x87" 
> "unsafe-fp-math"="false" "use-soft-float"="false" }


D'oh, that m_fn1 should have been Seek :/

$ cat t.ii

  struct LARGE {
union {
  int i;
};
  };
  struct I {
virtual void m_fn1(LARGE);
  };
  struct CBase {
virtual ~CBase();
  };
  struct C : CBase, I {
void m_fn1(LARGE);
  };
  void C::m_fn1(LARGE) {}

$ ~/llvm/Debug+Asserts/bin/clang -cc1 -x c++ -emit-llvm -triple 
i386-apple-darwin9 t.ii && grep tail t.ll

  tail call void @_ZN1C5m_fn1E5LARGE(%struct.C* %3, %struct.LARGE* byval align 
4 %0)


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread Gerolf Hoflehner via cfe-commits
Gerolf added a comment.

Nope, I don't see the tail call. Anyway, I'll simplify my test case. Don't 
worry about it.

clang++ -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.cpp

cat t.ll:

; ModuleID = 't.cpp'
source_filename = "t.cpp"
target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
target triple = "i386-apple-darwin9"

%struct.C = type { %struct.CBase, %struct.I }
%struct.CBase = type { i32 (...)** }
%struct.I = type { i32 (...)** }
%struct.LARGE = type { %union.anon }
%union.anon = type { i32 }

; Function Attrs: nounwind
define void @_ZN1C4SeekE5LARGE(%struct.C* %this, %struct.LARGE* byval align 4) 
#0 align 2 {
entry:

  %this.addr = alloca %struct.C*, align 4
  store %struct.C* %this, %struct.C** %this.addr, align 4
  %this1 = load %struct.C*, %struct.C** %this.addr, align 4
  ret void

}

attributes #0 = { nounwind "disable-tail-calls"="false" 
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"stack-protector-buffer-size"="8" "target-features"="+x87" 
"unsafe-fp-math"="false" "use-soft-float"="false" }


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread David Majnemer via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D22900#498781, @Gerolf wrote:

> Please add the options you used to compile? I can certainly shrink the test 
> case a bit before I commit.


clang -cc1 -x c++ -emit-llvm -triple i386-apple-darwin9 t.ii -o -


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread Gerolf Hoflehner via cfe-commits
Gerolf added a comment.

Please add the options you used to compile? I can certainly shrink the test 
case a bit before I commit.


https://reviews.llvm.org/D22900



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


Re: [PATCH] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer added a comment.

The test seems a little large, the following shows that we emit a tail call 
with a byval argument on trunk.

  struct LARGE {
union {
  int i;
};
  };
  struct I {
virtual void m_fn1(LARGE);
  };
  struct CBase {
virtual ~CBase();
  };
  struct C : CBase, I {
void Seek(LARGE);
  };
  void C::Seek(LARGE) {}


https://reviews.llvm.org/D22900



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


Re: [PATCH] D20168: [CodeGen] Handle structs directly in AMDGPUABIInfo

2016-07-27 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D20168



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


Re: [PATCH] D22691: [OpenMP] Codegen for use_device_ptr clause.

2016-07-27 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D22691



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


Re: [PATCH] D22895: [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-27 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D22895



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


Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-27 Thread Raphael Isemann via cfe-commits
teemperor added a comment.

Is there a specific situation/bug we want to test against with these tests? I 
looks to me as if they would mainly test against non-determinism (i.e. same 
statements have different data due to non-determinism).



Comment at: lib/Analysis/CloneDetection.cpp:113
@@ +112,3 @@
+
+  void addData(std::string const &String) {
+D.AddString(String);

v.g.vassilev wrote:
> Same here, `const std::string &String`. Is this caught by clang-format?
It hasn't complained so far or I'm missing a flag. But it's also accepting many 
non-LLVM like naming schemes, so I assume it's quite forgiving in this regard.


https://reviews.llvm.org/D22514



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


Re: only correct delayed typos for conditional expressions when needed.

2016-07-27 Thread Erik Pilkington via cfe-commits
Thanks for taking a look at this!

I have two comments:
 1. If we’re doing the check at the end of both branches of the if, we might as 
well just move it to after.
 2. It doesn’t make sense to have a failure that only occurs in C mode in 
test/SemaCXX. Maybe just append it to the end of test/Sema/typo-correction.c.

> On Jul 27, 2016, at 5:36 PM, David Tarditi via cfe-commits 
>  wrote:
> 
> r272587 (http://reviews.llvm.org/D20490 ) 
> fixed an issue where typo correction could cause a crash when compiling C 
> programs.The problem was that a typo expression could be inadvertently 
> processed twice.r272587 fixed this for BinOp expressions.   Conditional 
> expressions can hit the same problem too.  This change adds the two line fix 
> for them, as well as a small test case illustrating the crash.   This is my 
> first time proposing a patch for clang.  I don’t have commit privileges, so 
> if someone could review/commit this for me, I’d appreciate it.   If 
> Phrabicator is the preferred way or there’s another preferred process for 
> submitting patches, let me know.

Yes, Phabricator is the preferred method of getting a patch reviewed! Please 
submit any future patches there.

>  I see from the prior review that the consensus was that “typo correction is 
> in a messy state, we should fix this”. I agree.  There are other 
> problematic places in the code where double-processing might or might not 
> occur for C code.  An example is the processing of subscript expressions in 
> Parser::ParsePostfixExpressionSuffix.  Without clear invariants, it is hard 
> to know what to do.
>  
> Testing: clang fails on the test case without this change, passes with it.   
> The clang test suite results were otherwise the same before and after this 
> change.
>  
> Thanks,
> David
> ___
> 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] D22900: Revert r244207 - Mark calls in thunk functions as tail-call optimization

2016-07-27 Thread Gerolf Hoflehner via cfe-commits
Gerolf created this revision.
Gerolf added reviewers: eli.friedman, mkuper.
Gerolf added a subscriber: cfe-commits.

This is just closing the loop for
https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg28837.html with a
test case and fixes PR28748 which had been introduced by r244207.

https://reviews.llvm.org/D22900

Files:
  lib/CodeGen/CGVTables.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/CodeGenCXX/tail-byval.cpp

Index: test/CodeGenCXX/tail-byval.cpp
===
--- /dev/null
+++ test/CodeGenCXX/tail-byval.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 %s -I%S -isystem %S/Inputs -emit-llvm -triple i386-apple-darwin9 -Wno-incompatible-ms-struct -o - -Os | opt - -dse -S -o - | FileCheck %s
+#pragma ms_struct on
+
+#include 
+#include 
+
+extern "C" int rand();
+
+struct
+IByteStream
+{
+public:
+};
+
+
+class IEmpty {};
+
+class CRepro
+{
+protected:
+	CRepro( IEmpty* p) : mp(p) {};
+	virtual ~CRepro()  {}
+	
+	IEmpty* mp;
+};
+
+class BStream : public CRepro, public IByteStream
+{
+protected:
+	BStream( IEmpty *p);
+	virtual ~BStream(){} ;
+	
+protected:
+	int32_t Ref;
+};
+
+class CStream : public BStream
+{
+public:
+static uint32_t Create(uint32_t m, IByteStream **ppS, IEmpty *p);
+private:
+	CStream(bool fD, bool fZero,  IEmpty *p) ;
+};
+
+typedef union _LARGE {
+	struct {
+		uint32_t Low;
+		int32_t High;
+	} DUMMYSTRUCTNAME;
+	struct {
+		uint32_t Low;
+		int32_t High;
+	} u;
+	int64_t Quad;
+} LARGE;
+
+class I
+{
+public:
+	virtual uint32_t Seek(LARGE dlibMove, uint32_t Origin, LARGE *plibNP) = 0;
+	
+};
+
+class CBase : public CRepro
+{
+protected:
+	CBase(IByteStream *ps,  IEmpty *p);
+	virtual ~CBase() {};
+	
+protected:
+	uint64_t Offset;
+	uint32_t ThreadId;
+};
+
+class C : public CBase, public I
+{
+public:
+static uint32_t Create(IByteStream *ps,  wchar_t *w,  I **ppi,  IEmpty *p);
+	uint32_t Seek(LARGE dlibMove, uint32_t Origin, LARGE *plibNP);
+	
+private:
+	C(IByteStream *ps,  IEmpty *p) ;
+	~C() {};
+	
+};
+
+uint32_t C::Seek(LARGE dlibMove, uint32_t Origin, LARGE *plibNP)
+{
+	uint32_t hr = 1;
+	
+	if (Origin != 1 || dlibMove.Quad != 0)
+	{
+		if (ThreadId != 0 && ThreadId != (uint32_t)rand())
+		{
+			hr = 3;
+			goto LError;
+		}
+		
+		if (Origin == 0)
+		{
+			Offset = (uint64_t) dlibMove.Quad;
+		}
+	}
+	
+LError:
+	if (plibNP != NULL)
+		(*plibNP).Quad = Offset;
+	return hr;
+}
+// CHECK: define i32 @_ZThn20_N1C4SeekE6_LARGEjPS0_
+// CHECK: store i64
+// CHECK: ret
Index: test/CodeGenCXX/microsoft-abi-structors.cpp
===
--- test/CodeGenCXX/microsoft-abi-structors.cpp
+++ test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -177,7 +177,7 @@
 //  Do an adjustment from B* to C*.
 // DTORS2:   getelementptr i8, i8* %{{.*}}, i32 -4
 // DTORS2:   bitcast i8* %{{.*}} to %"struct.dtor_in_second_nvbase::C"*
-// DTORS2:   %[[CALL:.*]] = tail call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
+// DTORS2:   %[[CALL:.*]] = call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
 // DTORS2:   ret i8* %[[CALL]]
 
 }
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -322,8 +322,6 @@
   // Consider return adjustment if we have ThunkInfo.
   if (Thunk && !Thunk->Return.isEmpty())
 RV = PerformReturnAdjustment(*this, ResultType, RV, *Thunk);
-  else if (llvm::CallInst* Call = dyn_cast(CallOrInvoke))
-Call->setTailCallKind(llvm::CallInst::TCK_Tail);
 
   // Emit return.
   if (!ResultType->isVoidType() && Slot.isNull())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-27 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65857.
teemperor marked 5 inline comments as done.
teemperor added a comment.

- Removed duplicate test case.


https://reviews.llvm.org/D22514

Files:
  lib/Analysis/CloneDetection.cpp
  test/Analysis/copypaste/false-positives.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/test-asm.cpp
  test/Analysis/copypaste/test-attributes.cpp
  test/Analysis/copypaste/test-call.cpp
  test/Analysis/copypaste/test-catch.cpp
  test/Analysis/copypaste/test-delete.cpp
  test/Analysis/copypaste/test-dependent-exist.cpp
  test/Analysis/copypaste/test-expr-types.cpp
  test/Analysis/copypaste/test-fold.cpp
  test/Analysis/copypaste/test-function-try-block.cpp
  test/Analysis/copypaste/test-generic.c
  test/Analysis/copypaste/test-labels.cpp
  test/Analysis/copypaste/test-lambda.cpp
  test/Analysis/copypaste/test-try-body.cpp

Index: test/Analysis/copypaste/test-try-body.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-try-body.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if function try blocks are correctly handled.
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-lambda.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-lambda.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+void foo1(int a, long b) {
+  auto l = [a, b](){};
+}
+
+void foo2(int a, long b) {
+  auto l = [&a, b](){};
+}
+
+void foo3(int a, long b) {
+  auto l = [a](){};
+}
+
+void foo4(int a, long b) {
+  auto l = [=](){};
+}
+
+void foo5(int a, long b) {
+  auto l = [&](){};
+}
+
Index: test/Analysis/copypaste/test-labels.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-labels.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+
+bool foo1(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Targeting a different label with the address-of-label operator.
+bool foo2(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&end;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Different target label in goto
+bool foo3(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto end;
+  }
+  end:
+  return false;
+}
+
+// FIXME: Can't detect same algorithm as in foo1 but with different label names.
+bool foo4(int x) {
+  foo:
+  if (x != 3) {
+++x;
+void *ptr = &&foo;
+goto foo;
+  }
+  end:
+  return false;
+}
Index: test/Analysis/copypaste/test-generic.c
===
--- /dev/null
+++ test/Analysis/copypaste/test-generic.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -analyze -std=c11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global;
+
+int foo1() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, float: 2, default: 3);
+  return 1;
+}
+
+// Different associated type (int instead of float)
+int foo2() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, int: 2, default: 4);
+  return 1;
+}
+
+// Different number of associated types.
+int foo3() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, default: 4);
+  return 1;
+}
Index: test/Analysis/copypaste/test-function-try-block.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-function-try-block.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if the special case of a try
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-fold.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-fold.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global = 0;
+
+template
+int foo1(Args&&... args) {
+  if (global > 0)
+return 0;
+  else if 

Re: [PATCH] D22514: CloneDetection now respects statement specific data when searching for clones.

2016-07-27 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65854.
teemperor added a comment.

- Rebased patch.
- Fixed code style (`const type` instead of `type const`).
- Fixed missing const on some variables in StmtDataCollector.
- Rewrote a few comments/variable names.


https://reviews.llvm.org/D22514

Files:
  lib/Analysis/CloneDetection.cpp
  test/Analysis/copypaste/false-positives.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/test-asm.cpp
  test/Analysis/copypaste/test-attributes.cpp
  test/Analysis/copypaste/test-call.cpp
  test/Analysis/copypaste/test-catch.cpp
  test/Analysis/copypaste/test-delete.cpp
  test/Analysis/copypaste/test-dependent-exist.cpp
  test/Analysis/copypaste/test-expr-types.cpp
  test/Analysis/copypaste/test-fold.cpp
  test/Analysis/copypaste/test-function-try-block.cpp
  test/Analysis/copypaste/test-generic.c
  test/Analysis/copypaste/test-labels.cpp
  test/Analysis/copypaste/test-lambda.cpp
  test/Analysis/copypaste/test-try-body.cpp

Index: test/Analysis/copypaste/test-try-body.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-try-body.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if function try blocks are correctly handled.
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-lambda.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-lambda.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+void foo1(int a, long b) {
+  auto l = [a, b](){};
+}
+
+void foo2(int a, long b) {
+  auto l = [&a, b](){};
+}
+
+void foo3(int a, long b) {
+  auto l = [a](){};
+}
+
+void foo4(int a, long b) {
+  auto l = [=](){};
+}
+
+void foo5(int a, long b) {
+  auto l = [&](){};
+}
+
Index: test/Analysis/copypaste/test-labels.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-labels.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+
+bool foo1(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Targeting a different label with the address-of-label operator.
+bool foo2(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&end;
+goto start;
+  }
+  end:
+  return false;
+}
+
+// Different target label in goto
+bool foo3(int x) {
+  start:
+  if (x != 3) {
+++x;
+void *ptr = &&start;
+goto end;
+  }
+  end:
+  return false;
+}
+
+// FIXME: Can't detect same algorithm as in foo1 but with different label names.
+bool foo4(int x) {
+  foo:
+  if (x != 3) {
+++x;
+void *ptr = &&foo;
+goto foo;
+  }
+  end:
+  return false;
+}
Index: test/Analysis/copypaste/test-generic.c
===
--- /dev/null
+++ test/Analysis/copypaste/test-generic.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -analyze -std=c11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics
+
+int global;
+
+int foo1() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, float: 2, default: 3);
+  return 1;
+}
+
+// Different associated type (int instead of float)
+int foo2() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, int: 2, default: 4);
+  return 1;
+}
+
+// Different number of associated types.
+int foo3() {
+  if (global > 0)
+return 0;
+  else if (global < 0)
+return _Generic(global, double: 1, default: 4);
+  return 1;
+}
Index: test/Analysis/copypaste/test-function-try-block.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-function-try-block.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// Tests if the special case of a try
+
+void nonCompoundStmt1(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-warning{{Detected code clone.}}
+
+void nonCompoundStmt2(int& x)
+  try { x += 1; } catch(...) { x -= 1; } // expected-note{{Related code clone is here.}}
Index: test/Analysis/copypaste/test-fold.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-fold.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// expected-no-diagnostics

Re: [PATCH] D21946: Subject: [PATCH] [Driver] fix windows SDK detect

2016-07-27 Thread comicfans44 via cfe-commits
comicfans44 added a comment.

In https://reviews.llvm.org/D21946#473071, @zturner wrote:

> In https://reviews.llvm.org/D21946#473070, @comicfans44 wrote:
>
> > I've not commited to cfe before, so I think I havn't commit access 
> > permission.
>
>
> If you've committed anywhere in LLVM, you should have commit access to cfe.  
> Feel free to give it a try, as I won't be able to commit until Wednesday of 
> next week at the earliest anyway due to the upcoming holiday.


ping ?


https://reviews.llvm.org/D21946



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


r276950 - [analyzer] Add check::BeginFunction to CheckerDocumentation checks. NFC.

2016-07-27 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Jul 27 19:52:10 2016
New Revision: 276950

URL: http://llvm.org/viewvc/llvm-project?rev=276950&view=rev
Log:
[analyzer] Add check::BeginFunction to CheckerDocumentation checks. NFC.

This was an oversight from when I added BeginFunction support in r261293.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp?rev=276950&r1=276949&r2=276950&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp Wed Jul 27 
19:52:10 2016
@@ -45,6 +45,7 @@ class CheckerDocumentation : public Chec
check::Location,
check::Bind,
check::DeadSymbols,
+   check::BeginFunction,
check::EndFunction,
check::EndAnalysis,
check::EndOfTranslationUnit,


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


Re: [PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-27 Thread Saleem Abdulrasool via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r276948


https://reviews.llvm.org/D22881



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


[clang-tools-extra] r276949 - test: fix typo in file name (NFC)

2016-07-27 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Jul 27 19:43:14 2016
New Revision: 276949

URL: http://llvm.org/viewvc/llvm-project?rev=276949&view=rev
Log:
test: fix typo in file name (NFC)

Added:
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp
  - copied, changed from r276948, 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp
Removed:
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp

Removed: 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp?rev=276948&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp 
(removed)
@@ -1,8 +0,0 @@
-// RUN: clang-rename -offset=74 -new-name=Bar %s -- | FileCheck %s
-
-class Foo { // CHECK: class Bar {
-public:
-  void foo(int x);
-};
-
-void Foo::foo(int x) {} // CHECK: void Bar::foo(int x) {}

Copied: 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp 
(from r276948, 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp?p2=clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefinition.cpp&p1=clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp&r1=276948&r2=276949&rev=276949&view=diff
==
(empty)


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


[clang-tools-extra] r276948 - clang-rename: adjust NamedDeclFindingASTVisitor for RecordDecls

2016-07-27 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Jul 27 19:42:01 2016
New Revision: 276948

URL: http://llvm.org/viewvc/llvm-project?rev=276948&view=rev
Log:
clang-rename: adjust NamedDeclFindingASTVisitor for RecordDecls

Ensure that Context is always properly initialised in the constructor.  It is
used for querying the LangOpts in VisitTypeLoc.  Prevent a null pointer
dereference in setResult by ensuring that a RecordDecl is being handled.

Patch by Alexander Shaposhnikov!

Added:
clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=276948&r1=276947&r2=276948&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Wed Jul 27 19:42:01 2016
@@ -42,8 +42,9 @@ public:
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const std::string &Name)
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string &Name,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -75,9 +76,10 @@ public:
   bool VisitTypeLoc(const TypeLoc Loc) {
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-   TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@ const NamedDecl *getNamedDeclAt(const AS
 const NamedDecl *getNamedDeclFor(const ASTContext &Context,
  const std::string &Name) {
   const auto &SourceMgr = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, &Context);
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();

Added: clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp?rev=276948&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp 
(added)
+++ clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp 
Wed Jul 27 19:42:01 2016
@@ -0,0 +1,13 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
+


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


r276947 - Replace preserve-as-comments CodeGen test with driver test

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 19:36:34 2016
New Revision: 276947

URL: http://llvm.org/viewvc/llvm-project?rev=276947&view=rev
Log:
Replace preserve-as-comments CodeGen test with driver test

Added:
cfe/trunk/test/Driver/preserve-as-comments.c
Removed:
cfe/trunk/test/CodeGen/preserve-as-comments.c

Removed: cfe/trunk/test/CodeGen/preserve-as-comments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/preserve-as-comments.c?rev=276946&view=auto
==
--- cfe/trunk/test/CodeGen/preserve-as-comments.c (original)
+++ cfe/trunk/test/CodeGen/preserve-as-comments.c (removed)
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -S -triple=x86_64-unknown-unknown -fno-preserve-as-comments 
%s -o - | FileCheck %s --check-prefix=NOASM --check-prefix=CHECK
-// RUN: %clang_cc1 -S %s -triple=x86_64-unknown-unknown -o - | FileCheck %s 
--check-prefix=ASM --check-prefix=CHECK
-
-// CHECK-LABEL: main
-// CHECK: #APP
-// ASM: #comment
-// NOASM-NOT: #comment
-// CHECK: #NO_APP
-int main() {
-  __asm__("/*comment*/");
-  return 0;
-}

Added: cfe/trunk/test/Driver/preserve-as-comments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/preserve-as-comments.c?rev=276947&view=auto
==
--- cfe/trunk/test/Driver/preserve-as-comments.c (added)
+++ cfe/trunk/test/Driver/preserve-as-comments.c Wed Jul 27 19:36:34 2016
@@ -0,0 +1,2 @@
+// RUN: %clang -S -fno-preserve-as-comments %s -### 2>&1 | FileCheck %s
+// CHECK: "-fno-preserve-as-comments"


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


[PATCH] D22895: [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, 
kkwli0, tra.
sfantao added subscribers: cfe-commits, caomhin.

This patch prevents OpenMP flags from being forwarded to CUDA device commands. 
That was causing the CUDA frontend to attempt to emit OpenMP code which is not 
supported.

https://reviews.llvm.org/D22895

Files:
  lib/Driver/Tools.cpp
  test/Driver/offloading-interoperability.c

Index: test/Driver/offloading-interoperability.c
===
--- /dev/null
+++ test/Driver/offloading-interoperability.c
@@ -0,0 +1,17 @@
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Verify that CUDA device commands do not get OpenMP flags.
+//
+// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 
--cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
+//
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" 
"nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" 
"powerpc64le--linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" 
"--eh-frame-hdr" "-m" "elf64lppc"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5049,9 +5049,13 @@
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
   Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 
-  // Forward flags for OpenMP
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action.
+  //
+  // TODO: Allow OpenMP offload actions when they become available.
   if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
-   options::OPT_fno_openmp, false)) {
+   options::OPT_fno_openmp, false) &&
+  JA.isDeviceOffloading(Action::OFK_None)) {
 switch (getOpenMPRuntime(getToolChain(), Args)) {
 case OMPRT_OMP:
 case OMPRT_IOMP5:


Index: test/Driver/offloading-interoperability.c
===
--- /dev/null
+++ test/Driver/offloading-interoperability.c
@@ -0,0 +1,17 @@
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Verify that CUDA device commands do not get OpenMP flags.
+//
+// RUN: %clang -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
+//
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu"
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:  -fopenmp
+// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf64lppc"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5049,9 +5049,13 @@
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
   Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 
-  // Forward flags for OpenMP
+  // Forward flags for OpenMP. We don't do this if the current action is an
+  // device offloading action.
+  //
+  // TODO: Allow OpenMP offload actions when they become available.
   if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
-   options::OPT_fno_openmp, false)) {
+   options::OPT_fno_openmp, false) &&
+  JA.isDeviceOffloading(Action::OFK_None)) {
 switch (getOpenMPRuntime(getToolChain(), Args)) {
 case OMPRT_OMP:
 case OMPRT_IOMP5:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


only correct delayed typos for conditional expressions when needed.

2016-07-27 Thread David Tarditi via cfe-commits
r272587 (http://reviews.llvm.org/D20490) fixed an issue where typo correction 
could cause a crash when compiling C programs.The problem was that a typo 
expression could be inadvertently processed twice.r272587 fixed this for 
BinOp expressions.   Conditional expressions can hit the same problem too.  
This change adds the two line fix for them, as well as a small test case 
illustrating the crash.   This is my first time proposing a patch for clang.  I 
don't have commit privileges, so if someone could review/commit this for me, 
I'd appreciate it.   If Phrabicator is the preferred way or there's another 
preferred process for submitting patches, let me know.

I see from the prior review that the consensus was that "typo correction is in 
a messy state, we should fix this". I agree.  There are other problematic 
places in the code where double-processing might or might not occur for C code. 
 An example is the processing of subscript expressions in 
Parser::ParsePostfixExpressionSuffix.  Without clear invariants, it is hard to 
know what to do.

Testing: clang fails on the test case without this change, passes with it.   
The clang test suite results were otherwise the same before and after this 
change.

Thanks,
David


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


Re: r276350 - [CodeGen] Fix a crash when constant folding switch statement

2016-07-27 Thread David Majnemer via cfe-commits
I hear that he is on vacation.

On Wednesday, July 27, 2016, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Richard: ping?
>
> On Fri, Jul 22, 2016 at 7:00 AM, Hans Wennborg  > wrote:
> > Richard: should we merge this to 3.9?
> >
> > On Thu, Jul 21, 2016 at 6:31 PM, Erik Pilkington via cfe-commits
> > > wrote:
> >> Author: epilk
> >> Date: Thu Jul 21 17:31:40 2016
> >> New Revision: 276350
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=276350&view=rev
> >> Log:
> >> [CodeGen] Fix a crash when constant folding switch statement
> >>
> >> Differential revision: https://reviews.llvm.org/D22542
> >>
> >> Modified:
> >> cfe/trunk/lib/CodeGen/CGStmt.cpp
> >> cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=276350&r1=276349&r2=276350&view=diff
> >>
> ==
> >> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 21 17:31:40 2016
> >> @@ -1264,6 +1264,14 @@ void CodeGenFunction::EmitCaseStmt(const
> >>  }
> >>
> >>  void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
> >> +  // If there is no enclosing switch instance that we're aware of,
> then this
> >> +  // default statement can be elided. This situation only happens when
> we've
> >> +  // constant-folded the switch.
> >> +  if (!SwitchInsn) {
> >> +EmitStmt(S.getSubStmt());
> >> +return;
> >> +  }
> >> +
> >>llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
> >>assert(DefaultBlock->empty() &&
> >>   "EmitDefaultStmt: Default block already defined?");
> >>
> >> Modified: cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp?rev=276350&r1=276349&r2=276350&view=diff
> >>
> ==
> >> --- cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp (original)
> >> +++ cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp Thu Jul 21
> 17:31:40 2016
> >> @@ -18,4 +18,13 @@ int main(void) {
> >>   return test(5);
> >>  }
> >>
> >> +void other_test() {
> >> +  switch(0) {
> >> +  case 0:
> >> +do {
> >> +default:;
> >> +} while(0);
> >> +  }
> >> +}
> >> +
> >>  // CHECK: call i32 (i8*, ...) @_Z6printfPKcz
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org 
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r276350 - [CodeGen] Fix a crash when constant folding switch statement

2016-07-27 Thread Hans Wennborg via cfe-commits
Richard: ping?

On Fri, Jul 22, 2016 at 7:00 AM, Hans Wennborg  wrote:
> Richard: should we merge this to 3.9?
>
> On Thu, Jul 21, 2016 at 6:31 PM, Erik Pilkington via cfe-commits
>  wrote:
>> Author: epilk
>> Date: Thu Jul 21 17:31:40 2016
>> New Revision: 276350
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276350&view=rev
>> Log:
>> [CodeGen] Fix a crash when constant folding switch statement
>>
>> Differential revision: https://reviews.llvm.org/D22542
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGStmt.cpp
>> cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=276350&r1=276349&r2=276350&view=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 21 17:31:40 2016
>> @@ -1264,6 +1264,14 @@ void CodeGenFunction::EmitCaseStmt(const
>>  }
>>
>>  void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
>> +  // If there is no enclosing switch instance that we're aware of, then this
>> +  // default statement can be elided. This situation only happens when we've
>> +  // constant-folded the switch.
>> +  if (!SwitchInsn) {
>> +EmitStmt(S.getSubStmt());
>> +return;
>> +  }
>> +
>>llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
>>assert(DefaultBlock->empty() &&
>>   "EmitDefaultStmt: Default block already defined?");
>>
>> Modified: cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp?rev=276350&r1=276349&r2=276350&view=diff
>> ==
>> --- cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/switch-case-folding-2.cpp Thu Jul 21 17:31:40 
>> 2016
>> @@ -18,4 +18,13 @@ int main(void) {
>>   return test(5);
>>  }
>>
>> +void other_test() {
>> +  switch(0) {
>> +  case 0:
>> +do {
>> +default:;
>> +} while(0);
>> +  }
>> +}
>> +
>>  // CHECK: call i32 (i8*, ...) @_Z6printfPKcz
>>
>>
>> ___
>> 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


Re: r276900 - [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

2016-07-27 Thread Hans Wennborg via cfe-commits
Should this be merged to 3.9?

Thanks,
Hans

On Wed, Jul 27, 2016 at 11:25 AM, Erik Pilkington via cfe-commits
 wrote:
> Author: epilk
> Date: Wed Jul 27 13:25:10 2016
> New Revision: 276900
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276900&view=rev
> Log:
> [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer
>
> Fixes PR27994, a crash on valid.
>
> Differential revision: https://reviews.llvm.org/D21145
>
> Modified:
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=276900&r1=276899&r2=276900&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 27 13:25:10 2016
> @@ -961,32 +961,26 @@ static QualType adjustCVQualifiersForCXX
>  QualType Sema::getCurrentThisType() {
>DeclContext *DC = getFunctionLevelDeclContext();
>QualType ThisTy = CXXThisTypeOverride;
> +
>if (CXXMethodDecl *method = dyn_cast(DC)) {
>  if (method && method->isInstance())
>ThisTy = method->getThisType(Context);
>}
> -  if (ThisTy.isNull()) {
> -if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
> -CurContext->getParent()->getParent()->isRecord()) {
> -  // This is a generic lambda call operator that is being instantiated
> -  // within a default initializer - so use the enclosing class as 'this'.
> -  // There is no enclosing member function to retrieve the 'this' pointer
> -  // from.
> -
> -  // FIXME: This looks wrong. If we're in a lambda within a lambda 
> within a
> -  // default member initializer, we need to recurse up more parents to 
> find
> -  // the right context. Looks like we should be walking up to the parent 
> of
> -  // the closure type, checking whether that is itself a lambda, and if 
> so,
> -  // recursing, until we reach a class or a function that isn't a lambda
> -  // call operator. And we should accumulate the constness of *this on 
> the
> -  // way.
> -
> -  QualType ClassTy = Context.getTypeDeclType(
> -  cast(CurContext->getParent()->getParent()));
> -  // There are no cv-qualifiers for 'this' within default initializers,
> -  // per [expr.prim.general]p4.
> -  ThisTy = Context.getPointerType(ClassTy);
> -}
> +
> +  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
> +  !ActiveTemplateInstantiations.empty()) {
> +
> +assert(isa(DC) &&
> +   "Trying to get 'this' type from static method?");
> +
> +// This is a lambda call operator that is being instantiated as a default
> +// initializer. DC must point to the enclosing class type, so we can 
> recover
> +// the 'this' type from it.
> +
> +QualType ClassTy = Context.getTypeDeclType(cast(DC));
> +// There are no cv-qualifiers for 'this' within default initializers,
> +// per [expr.prim.general]p4.
> +ThisTy = Context.getPointerType(ClassTy);
>}
>
>// If we are within a lambda's call operator, the cv-qualifiers of 'this'
>
> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=276900&r1=276899&r2=276900&view=diff
> ==
> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Wed Jul 27 13:25:10 2016
> @@ -1,5 +1,4 @@
> -// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify 
> -fblocks %s
> -// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify 
> -fblocks %s
> +// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
> -fblocks %s
>
>  namespace std { class type_info; };
>
> @@ -499,3 +498,30 @@ void foo() {
>};
>  }
>  }
> +
> +namespace PR27994 {
> +struct A { template  A(T); };
> +
> +template 
> +struct B {
> +  int x;
> +  A a = [&] { int y = x; };
> +  A b = [&] { [&] { [&] { int y = x; }; }; };
> +  A d = [&](auto param) { int y = x; };
> +  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
> +};
> +
> +B b;
> +
> +template  struct C {
> +  struct D {
> +int x;
> +A f = [&] { int y = x; };
> +  };
> +};
> +
> +int func() {
> +  C a;
> +  decltype(a)::D b;
> +}
> +}
>
>
> ___
> 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


Re: r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Renato Golin via cfe-commits
On 27 July 2016 at 21:57, Nirav Davé  wrote:
> Looks like I missed the target triple. Should work now.

Still failing on *all* ARM targets.

'No available targets are compatible with this triple.'

Please move the test to an x86 directory.

http://llvm.org/docs/TestingGuide.html#platform-specific-tests

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


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276937: Retry: [Driver] Compute effective target triples 
once per job (NFCI) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D22596?vs=64792&id=65829#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22596

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -40,6 +40,7 @@
   class Compilation;
   class Driver;
   class JobAction;
+  class RegisterEffectiveTriple;
   class SanitizerArgs;
   class Tool;
 
@@ -91,6 +92,14 @@
 
   mutable std::unique_ptr SanitizerArguments;
 
+  /// The effective clang triple for the current Job.
+  mutable llvm::Triple EffectiveTriple;
+
+  /// Set the toolchain's effective clang triple.
+  void setEffectiveTriple(llvm::Triple ET) const { EffectiveTriple = ET; }
+
+  friend class RegisterEffectiveTriple;
+
 protected:
   MultilibSet Multilibs;
   const char *DefaultLinker = "ld";
@@ -141,6 +150,12 @@
 return Triple.getTriple();
   }
 
+  /// Get the toolchain's effective clang triple.
+  const llvm::Triple &getEffectiveTriple() const {
+assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
+return EffectiveTriple;
+  }
+
   path_list &getFilePaths() { return FilePaths; }
   const path_list &getFilePaths() const { return FilePaths; }
 
@@ -432,6 +447,19 @@
   virtual VersionTuple getMSVCVersionFromExe() const { return VersionTuple(); }
 };
 
+/// Set a ToolChain's effective triple. Reset it when the registration object
+/// is destroyed.
+class RegisterEffectiveTriple {
+  const ToolChain &TC;
+
+public:
+  RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) {
+TC.setEffectiveTriple(T);
+  }
+
+  ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
+};
+
 } // end namespace driver
 } // end namespace clang
 
Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -312,9 +312,6 @@
   /// @name ToolChain Implementation
   /// {
 
-  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
-  types::ID InputType) const override;
-
   types::ID LookupTypeForExtension(const char *Ext) const override;
 
   bool HasNativeLLVMSupport() const override;
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -176,13 +176,6 @@
 
 MachO::~MachO() {}
 
-std::string MachO::ComputeEffectiveClangTriple(const ArgList &Args,
-   types::ID InputType) const {
-  llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
-
-  return Triple.getTriple();
-}
-
 std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
 types::ID InputType) const {
   llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -764,7 +764,7 @@
 // -mfloat-abi=.
 arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
   const Driver &D = TC.getDriver();
-  const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(Args));
+  const llvm::Triple &Triple = TC.getEffectiveTriple();
   auto SubArch = getARMSubArchVersionNumber(Triple);
   arm::FloatABI ABI = FloatABI::Invalid;
   if (Arg *A =
@@ -1165,8 +1165,7 @@
 
 void Clang::AddAArch64TargetArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
   if (!Args.hasFlag(options::OPT_mred_zone, options::OPT_mno_red_zone, true) ||
   Args.hasArg(options::OPT_mkernel) ||
@@ -3838,8 +3837,8 @@
 void Clang::ConstructJob(Compilation &C, const JobAction &JA,
  const InputInfo &Output, const InputInfoList &Inputs,
  const ArgList &Args, const char *LinkingOutput) const {
-  std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
-  const llvm::Triple Triple(TripleStr);
+  const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const std::string &TripleStr = Triple.getTriple();
 
   bool KernelOrKe

r276937 - Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Jul 27 18:02:20 2016
New Revision: 276937

URL: http://llvm.org/viewvc/llvm-project?rev=276937&view=rev
Log:
Retry: [Driver] Compute effective target triples once per job (NFCI)

Compute an effective triple once per job. Cache the triple in the
prevailing ToolChain for the duration of the job.

Clients which need effective triples now look them up in the ToolChain.
This eliminates wasteful re-computation of effective triples (e.g in
getARMFloatABI()).

While we're at it, delete MachO::ComputeEffectiveClangTriple. It was a
no-op override.

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

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=276937&r1=276936&r2=276937&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Jul 27 18:02:20 2016
@@ -40,6 +40,7 @@ namespace driver {
   class Compilation;
   class Driver;
   class JobAction;
+  class RegisterEffectiveTriple;
   class SanitizerArgs;
   class Tool;
 
@@ -91,6 +92,14 @@ private:
 
   mutable std::unique_ptr SanitizerArguments;
 
+  /// The effective clang triple for the current Job.
+  mutable llvm::Triple EffectiveTriple;
+
+  /// Set the toolchain's effective clang triple.
+  void setEffectiveTriple(llvm::Triple ET) const { EffectiveTriple = ET; }
+
+  friend class RegisterEffectiveTriple;
+
 protected:
   MultilibSet Multilibs;
   const char *DefaultLinker = "ld";
@@ -141,6 +150,12 @@ public:
 return Triple.getTriple();
   }
 
+  /// Get the toolchain's effective clang triple.
+  const llvm::Triple &getEffectiveTriple() const {
+assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
+return EffectiveTriple;
+  }
+
   path_list &getFilePaths() { return FilePaths; }
   const path_list &getFilePaths() const { return FilePaths; }
 
@@ -432,6 +447,19 @@ public:
   virtual VersionTuple getMSVCVersionFromExe() const { return VersionTuple(); }
 };
 
+/// Set a ToolChain's effective triple. Reset it when the registration object
+/// is destroyed.
+class RegisterEffectiveTriple {
+  const ToolChain &TC;
+
+public:
+  RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) {
+TC.setEffectiveTriple(T);
+  }
+
+  ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
+};
+
 } // end namespace driver
 } // end namespace clang
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=276937&r1=276936&r2=276937&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jul 27 18:02:20 2016
@@ -2247,6 +2247,19 @@ InputInfo Driver::BuildJobsForActionNoCa
 InputInfos.append(OffloadDependencesInputInfo.begin(),
   OffloadDependencesInputInfo.end());
 
+  // Set the effective triple of the toolchain for the duration of this job.
+  llvm::Triple EffectiveTriple;
+  const ToolChain &ToolTC = T->getToolChain();
+  const ArgList &Args = C.getArgsForToolChain(TC, BoundArch);
+  if (InputInfos.size() != 1) {
+EffectiveTriple = llvm::Triple(ToolTC.ComputeEffectiveClangTriple(Args));
+  } else {
+// Pass along the input type if it can be unambiguously determined.
+EffectiveTriple = llvm::Triple(
+ToolTC.ComputeEffectiveClangTriple(Args, InputInfos[0].getType()));
+  }
+  RegisterEffectiveTriple TripleRAII(ToolTC, EffectiveTriple);
+
   // Determine the place to write output to, if any.
   InputInfo Result;
   if (JA->getType() == types::TY_Nothing)

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=276937&r1=276936&r2=276937&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Jul 27 18:02:20 2016
@@ -68,7 +68,8 @@ static ToolChain::RTTIMode CalculateRTTI
 ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
  const ArgList &Args)
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
-  CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
+  CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)),
+  EffectiveTriple() {
   if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
 if (!isThreadModelSupported(A->getValue()))
   D.Diag(diag::err_drv_invalid_thread_model_for_target)

Modified: cfe/trunk/lib/Dr

r276936 - Revert "[Driver] Compute effective target triples once per job (NFCI)"

2016-07-27 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Jul 27 18:01:55 2016
New Revision: 276936

URL: http://llvm.org/viewvc/llvm-project?rev=276936&view=rev
Log:
Revert "[Driver] Compute effective target triples once per job (NFCI)"

This reverts commit r275895 in order to address some post-commit review
feedback from Eric Christopher (see: the list thread for r275895).

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Driver/Tool.h
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=276936&r1=276935&r2=276936&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jul 27 18:01:55 2016
@@ -121,8 +121,7 @@ These are major API changes that have ha
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
-- Classes which inherit from ``driver::Tool`` must be updated to use effective
-  target triples when constructing jobs.
+-  ...
 
 AST Matchers
 

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=276936&r1=276935&r2=276936&view=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Wed Jul 27 18:01:55 2016
@@ -16,10 +16,6 @@
 #include 
 #include 
 
-namespace llvm {
-class Triple;
-}
-
 namespace clang {
 namespace driver {
 
@@ -70,8 +66,7 @@ class SanitizerArgs {
   bool requiresPIE() const;
   bool needsUnwindTables() const;
   bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
-  void addArgs(const ToolChain &TC, const llvm::Triple &EffectiveTriple,
-   const llvm::opt::ArgList &Args,
+  void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
 };
 

Modified: cfe/trunk/include/clang/Driver/Tool.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Tool.h?rev=276936&r1=276935&r2=276936&view=diff
==
--- cfe/trunk/include/clang/Driver/Tool.h (original)
+++ cfe/trunk/include/clang/Driver/Tool.h Wed Jul 27 18:01:55 2016
@@ -14,7 +14,6 @@
 #include "llvm/Support/Program.h"
 
 namespace llvm {
-class Triple;
 namespace opt {
   class ArgList;
 }
@@ -128,7 +127,6 @@ public:
   virtual void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output,
 const InputInfoList &Inputs,
-const llvm::Triple &EffectiveTriple,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const = 0;
 };

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=276936&r1=276935&r2=276936&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Jul 27 18:01:55 2016
@@ -260,13 +260,11 @@ public:
 return ToolChain::CST_Libstdcxx;
   }
 
-  virtual std::string getCompilerRT(const llvm::Triple &EffectiveTriple,
-const llvm::opt::ArgList &Args,
+  virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
 StringRef Component,
 bool Shared = false) const;
 
-  const char *getCompilerRTArgString(const llvm::Triple &EffectiveTriple,
- const llvm::opt::ArgList &Args,
+  const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
  StringRef Component,
  bool Shared = false) const;
   /// needsProfileRT - returns true if instrumentation profile is on.
@@ -412,8 +410,7 @@ public:
   const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
   /// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
   /// a suitable profile runtime library to the linker.
-  virtual void addProfileRTLibs(const llvm::Triple &EffectiveTriple,
-const llvm::opt::ArgList &Args,
+  virtual void addProfileR

r276934 - [OpenMP] Add support to map member expressions with references to pointers.

2016-07-27 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Wed Jul 27 17:52:16 2016
New Revision: 276934

URL: http://llvm.org/viewvc/llvm-project?rev=276934&view=rev
Log:
[OpenMP] Add support to map member expressions with references to pointers.

Summary: This patch add support to map pointers through references in class 
members. Although a reference does not have storage that a user can access, it 
still has to be mapped in order to get the deep copy right and the 
dereferencing code work properly.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=276934&r1=276933&r2=276934&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Jul 27 17:52:16 2016
@@ -5320,14 +5320,34 @@ private:
 isa(Next->getAssociatedExpression())) &&
"Unexpected expression");
 
-// Save the base we are currently using.
-BasePointers.push_back(BP);
-
 auto *LB = CGF.EmitLValue(I->getAssociatedExpression()).getPointer();
 auto *Size = getExprTypeSize(I->getAssociatedExpression());
 
+// If we have a member expression and the current component is a
+// reference, we have to map the reference too. Whenever we have a
+// reference, the section that reference refers to is going to be a
+// load instruction from the storage assigned to the reference.
+if (isa(I->getAssociatedExpression()) &&
+I->getAssociatedDeclaration()->getType()->isReferenceType()) {
+  auto *LI = cast(LB);
+  auto *RefAddr = LI->getPointerOperand();
+
+  BasePointers.push_back(BP);
+  Pointers.push_back(RefAddr);
+  Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
+  Types.push_back(getMapTypeBits(
+  /*MapType*/ OMPC_MAP_alloc, /*MapTypeModifier=*/OMPC_MAP_unknown,
+  !IsExpressionFirstInfo, IsCaptureFirstInfo));
+  IsExpressionFirstInfo = false;
+  IsCaptureFirstInfo = false;
+  // The reference will be the next base address.
+  BP = RefAddr;
+}
+
+BasePointers.push_back(BP);
 Pointers.push_back(LB);
 Sizes.push_back(Size);
+
 // We need to add a pointer flag for each map that comes from the
 // same expression except for the first one. We also need to signal
 // this map is the first one that relates with the current capture

Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_codegen.cpp?rev=276934&r1=276933&r2=276934&view=diff
==
--- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Wed Jul 27 17:52:16 2016
@@ -4564,4 +4564,193 @@ void explicit_maps_pointer_references (i
   }
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK29 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK29 --check-prefix CK29-64
+// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK29 --check-prefix CK29-64
+// RUN: %clang_cc1 -DCK29 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu 
-x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK29 --check-prefix CK29-32
+// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK29 --check-prefix CK29-32
+#ifdef CK29
+
+// CK29: [[SSA:%.+]] = type { double*, double** }
+// CK29: [[SSB:%.+]]  = type { [[SSA]]*, [[SSA]]** }
+
+// CK29: [[SIZE00:@.+]] = private {{.*}}constant [4 x i[[Z:64|32]]] 
[i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] 
80]
+// CK29: [[MTYPE00:@.+]] = private {{.*}}constant [4 x i32] [i32 35, i32 16, 
i32 19, i32 19]
+
+// CK29: [[SIZE01:@.+]] = private {{.*}}constant [4 x i[[Z]]] [i[[Z]] 

r276933 - [OpenMP] Add support for mapping array sections through pointer references.

2016-07-27 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Wed Jul 27 17:49:49 2016
New Revision: 276933

URL: http://llvm.org/viewvc/llvm-project?rev=276933&view=rev
Log:
[OpenMP] Add support for mapping array sections through pointer references.

Summary:
This patch fixes a bug in the map of array sections whose base is a reference 
to a pointer. The existing mapping support was not prepared to deal with it, 
causing the compiler to crash.

Mapping a reference to a pointer enjoys the same characteristics of a regular 
pointer, i.e., it is passed by value. Therefore, the reference has to be 
materialized in the target region.

Reviewers: hfinkel, carlo.bertolli, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=276933&r1=276932&r2=276933&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Jul 27 17:49:49 2016
@@ -5271,15 +5271,13 @@ private:
 
   // If the variable is a pointer and is being dereferenced (i.e. is not
   // the last component), the base has to be the pointer itself, not its
-  // reference.
-  if (I->getAssociatedDeclaration()->getType()->isAnyPointerType() &&
-  std::next(I) != CE) {
-auto PtrAddr = CGF.MakeNaturalAlignAddrLValue(
-BP, I->getAssociatedDeclaration()->getType());
+  // reference. References are ignored for mapping purposes.
+  QualType Ty =
+  I->getAssociatedDeclaration()->getType().getNonReferenceType();
+  if (Ty->isAnyPointerType() && std::next(I) != CE) {
+auto PtrAddr = CGF.MakeNaturalAlignAddrLValue(BP, Ty);
 BP = CGF.EmitLoadOfPointerLValue(PtrAddr.getAddress(),
- I->getAssociatedDeclaration()
- ->getType()
- ->getAs())
+ Ty->castAs())
  .getPointer();
 
 // We do not need to generate individual map information for the

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=276933&r1=276932&r2=276933&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Jul 27 17:49:49 2016
@@ -264,7 +264,17 @@ CodeGenFunction::GenerateOpenMPCapturedS
 // If we are capturing a pointer by copy we don't need to do anything, just
 // use the value that we get from the arguments.
 if (I->capturesVariableByCopy() && FD->getType()->isAnyPointerType()) {
-  setAddrOfLocalVar(I->getCapturedVar(), GetAddrOfLocalVar(Args[Cnt]));
+  const VarDecl *CurVD = I->getCapturedVar();
+  Address LocalAddr = GetAddrOfLocalVar(Args[Cnt]);
+  // If the variable is a reference we need to materialize it here.
+  if (CurVD->getType()->isReferenceType()) {
+Address RefAddr = CreateMemTemp(CurVD->getType(), getPointerAlign(),
+".materialized_ref");
+EmitStoreOfScalar(LocalAddr.getPointer(), RefAddr, /*Volatile=*/false,
+  CurVD->getType());
+LocalAddr = RefAddr;
+  }
+  setAddrOfLocalVar(CurVD, LocalAddr);
   ++Cnt;
   ++I;
   continue;

Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_codegen.cpp?rev=276933&r1=276932&r2=276933&view=diff
==
--- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Wed Jul 27 17:49:49 2016
@@ -60,12 +60,15 @@ void implicit_maps_integer (int a){
 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK2 --check-prefix CK2-32
 #ifdef CK2
 
-// CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
+// CK2: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
 // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
-// CK2-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[SIZES2:@.+]] = {{.+}}constant [1 x i[[sz]]] zeroinitializer
+// Map types: OMP_MAP_IS_PTR = 32
+// CK2: [[TYPES2:@.+]] = {{.+}}constant [1 x i32] [i32 32]
 
-// CK2-LABEL: implicit_maps_integer_reference
-void

Re: [PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-07-27 Thread Martin Probst via cfe-commits
mprobst added a comment.

Friendly ping :-)


https://reviews.llvm.org/D22431



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


r276930 - test/Frontend: Add a test for aarch64 target CPU names.

2016-07-27 Thread Matthias Braun via cfe-commits
Author: matze
Date: Wed Jul 27 17:47:07 2016
New Revision: 276930

URL: http://llvm.org/viewvc/llvm-project?rev=276930&view=rev
Log:
test/Frontend: Add a test for aarch64 target CPU names.

Nothing else checked the target cpu names for aarch64 yet.
Add a test in the spirit of x86-target-cpu.c.

Added:
cfe/trunk/test/Frontend/aarch64-target-cpu.c

Added: cfe/trunk/test/Frontend/aarch64-target-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/aarch64-target-cpu.c?rev=276930&view=auto
==
--- cfe/trunk/test/Frontend/aarch64-target-cpu.c (added)
+++ cfe/trunk/test/Frontend/aarch64-target-cpu.c Wed Jul 27 17:47:07 2016
@@ -0,0 +1,14 @@
+// Ensure we support the various CPU names.
+//
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a35 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a53 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a57 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a72 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cortex-a73 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu cyclone -verify 
%s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu exynos-m1 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu generic -verify 
%s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu kryo -verify %s
+// RUN: %clang_cc1 -triple aarch64-unknown-unknown -target-cpu vulcan -verify 
%s
+//
+// expected-no-diagnostics


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


r276931 - Basic/Targets.cpp: Reformat aarch64 CPU list.

2016-07-27 Thread Matthias Braun via cfe-commits
Author: matze
Date: Wed Jul 27 17:47:09 2016
New Revision: 276931

URL: http://llvm.org/viewvc/llvm-project?rev=276931&view=rev
Log:
Basic/Targets.cpp: Reformat aarch64 CPU list.

Having 1 entry per line and an alphabetical order is clearer and reduces
the risk of invalid merges.

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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=276931&r1=276930&r2=276931&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 27 17:47:09 2016
@@ -5727,14 +5727,17 @@ public:
 
   bool setCPU(const std::string &Name) override {
 bool CPUKnown = llvm::StringSwitch(Name)
-.Case("generic", true)
-.Cases("cortex-a53", "cortex-a57", "cortex-a72",
-   "cortex-a35", "exynos-m1", true)
-.Case("cortex-a73", true)
-.Case("cyclone", true)
-.Case("kryo", true)
-.Case("vulcan", true)
-.Default(false);
+  .Case("cortex-a35", true)
+  .Case("cortex-a53", true)
+  .Case("cortex-a57", true)
+  .Case("cortex-a72", true)
+  .Case("cortex-a73", true)
+  .Case("cyclone", true)
+  .Case("exynos-m1", true)
+  .Case("generic", true)
+  .Case("kryo", true)
+  .Case("vulcan", true)
+  .Default(false);
 return CPUKnown;
   }
 


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


r276929 - Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Wed Jul 27 17:46:31 2016
New Revision: 276929

URL: http://llvm.org/viewvc/llvm-project?rev=276929&view=rev
Log:
Refactor how include paths are appended to the command arguments.

Summary:
This patch aims at removing redundancy in the way include paths for the regular 
and offloading toolchains are appended to the arguments list in the clang tool.

This was suggested by @rsmith in response to r275931.

Reviewers: rsmith, tra

Subscribers: rsmith, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cuda-version-check.cu

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276929&r1=276928&r2=276929&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 17:46:31 2016
@@ -296,56 +296,25 @@ static bool forwardToGCC(const Option &O
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
-/// Add the C++ include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadCXXStdlibIncludeArgs(Compilation &C,
-const JobAction &JA,
-const ArgList &Args,
-ArgStringList &CmdArgs) {
+/// Apply \a Work on the current tool chain \a RegularToolChain and any other
+/// offloading tool chain that is associated with the current action \a JA.
+static void
+forAllAssociatedToolChains(Compilation &C, const JobAction &JA,
+   const ToolChain &RegularToolChain,
+   llvm::function_ref Work) {
+  // Apply Work on the current/regular tool chain.
+  Work(RegularToolChain);
 
+  // Apply Work on all the offloading tool chains associated with the current
+  // action.
   if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
   else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()
-->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+Work(*C.getSingleOffloadToolChain());
 
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the C include args of other offloading toolchains. If this is a host
-/// job, the device toolchains are added. If this is a device job, the host
-/// toolchains will be added.
-static void addExtraOffloadClangSystemIncludeArgs(Compilation &C,
-  const JobAction &JA,
-  const ArgList &Args,
-  ArgStringList &CmdArgs) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddClangSystemIncludeArgs(
-Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
-}
-
-/// Add the include args that are specific of each offloading programming 
model.
-static void addExtraOffloadSpecificIncludeArgs(Compilation &C,
-   const JobAction &JA,
-   const ArgList &Args,
-   ArgStringList &CmdArgs) {
-
-  if (JA.isHostOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-  else if (JA.isDeviceOffloading(Action::OFK_Cuda))
-C.getSingleOffloadToolChain()->AddCudaIncludeArgs(
-Args, CmdArgs);
-
-  // TODO: Add support for other programming models here.
+  //
+  // TODO: Add support for other offloading programming models here.
+  //
 }
 
 void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
@@ -622,22 +591,26 @@ void Clang::AddPreprocessingOptions(Comp
   // of an offloading programming model.
 
   // Add C++ include arguments, if needed.
-  if (types::isCXX(Inputs[0].getType())) {
-getToolChain().AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-addExtraOffloadCXXStdlibIncludeArgs(C, JA, Args, CmdArgs);
-  }
+  if (types::isCXX(Inputs[0].getType()))
+forAllAssociatedToolChains(C, JA, getToolChain(),
+   [&Args, &CmdArgs](const ToolChain &TC) {
+ TC.AddClangCXXStdlibIncludeArgs(Args, 
CmdArgs);
+   });
 
   // Add system include arguments for all targets but IAMCU.
-  if (!IsIAMCU) {
-getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
-addExtraOffloadCla

Re: [PATCH] D20811: [analyzer] Model some library functions

2016-07-27 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:509
@@ +508,3 @@
+  //}
+  //  }
+  //}

I disagree about compactness being valuable here. I think it is more important 
to intrinsically document the spec. These will be written once and read 
frequently. When they are written, they will copied from a previous example -- 
probably by someone who is not familiar with the code or the spec format.

Another possibility (not sure if it is the right one here) is to use macro 
tricks to define a simple DSL like Kulpreet did in the LocalizationChecker.cpp.


https://reviews.llvm.org/D20811



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276927: [CUDA] Align kernel launch args correctly when the 
LLVM type's alignment is… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D22879?vs=65800&id=65824#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22879

Files:
  cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu

Index: cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
===
--- cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
+++ cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
+// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+
+#include "Inputs/cuda.h"
+
+struct U {
+  short x;
+} __attribute__((packed));
+
+struct S {
+  int *ptr;
+  char a;
+  U u;
+};
+
+// Clang should generate a packed LLVM struct for S (denoted by the <>s),
+// otherwise this test isn't interesting.
+// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+
+static_assert(alignof(S) == 8, "Unexpected alignment.");
+
+// HOST-LABEL: @_Z6kernelc1SPi
+// Marshalled kernel args should be:
+//   1. offset 0, width 1
+//   2. offset 8 (because alignof(S) == 8), width 16
+//   3. offset 24, width 8
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
+
+// DEVICE-LABEL: @_Z6kernelc1SPi
+// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+__global__ void kernel(char a, S s, int *b) {}
Index: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
@@ -99,6 +99,12 @@
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
   ArgTypes.push_back(Args[I].RV.getScalarVal()->getType());
+
+// Using llvm::StructType is correct only because printf doesn't accept
+// aggregates.  If we had to handle aggregates here, we'd have to manually
+// compute the offsets within the alloca -- we wouldn't be able to assume
+// that the alignment of the llvm type was the same as the alignment of the
+// clang type.
 llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_args");
 llvm::Value *Alloca = CreateTempAlloca(AllocaTy);
 
Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp
@@ -118,37 +118,28 @@
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction &CGF,
  FunctionArgList &Args) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSit

r276927 - [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul 27 17:36:21 2016
New Revision: 276927

URL: http://llvm.org/viewvc/llvm-project?rev=276927&view=rev
Log:
[CUDA] Align kernel launch args correctly when the LLVM type's alignment is 
different from the clang type's alignment.

Summary:
Before this patch, we computed the offsets in memory of args passed to
GPU kernel functions by throwing all of the args into an LLVM struct.

clang emits packed llvm structs basically whenever it feels like it, and
packed structs have alignment 1.  So we cannot rely on the llvm type's
alignment matching the C++ type's alignment.

This patch fixes our codegen so we always respect the clang types'
alignments.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Added:
cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
Modified:
cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp

Modified: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp?rev=276927&r1=276926&r2=276927&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp Wed Jul 27 17:36:21 2016
@@ -99,6 +99,12 @@ CodeGenFunction::EmitCUDADevicePrintfCal
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
   ArgTypes.push_back(Args[I].RV.getScalarVal()->getType());
+
+// Using llvm::StructType is correct only because printf doesn't accept
+// aggregates.  If we had to handle aggregates here, we'd have to manually
+// compute the offsets within the alloca -- we wouldn't be able to assume
+// that the alignment of the llvm type was the same as the alignment of the
+// clang type.
 llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_args");
 llvm::Value *Alloca = CreateTempAlloca(AllocaTy);
 

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=276927&r1=276926&r2=276927&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Wed Jul 27 17:36:21 2016
@@ -118,37 +118,28 @@ void CGNVCUDARuntime::emitDeviceStub(Cod
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction &CGF,
  FunctionArgList &Args) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-
ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
 llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero);
+llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
 CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock);
 CGF.EmitBlock(NextBlock);
+Offset += TyWidth;
   }
 
   // Emit the call to cudaLaunch

Added: cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu?rev=276927&vie

Re: [PATCH] D22636: Module: retry building modules that were just compiled by the same instance and are are out of date

2016-07-27 Thread Manman Ren via cfe-commits
manmanren abandoned this revision.
manmanren added a comment.

Abandon this change for now.


https://reviews.llvm.org/D22636



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D22879



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added a comment.

Ok, sounds good. Feel free to abandon this one as well.

cheers,
--renato


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22856: [analyzer] Change -analyze-function to accept qualified names.

2016-07-27 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D22856#497796, @NoQ wrote:

> > I think it would be better for fully-qualified Objective-C methods to be 
> > specified with their Objective-C-style names. For example: "-[Test1 
> > myMethodWithY:withX:]".
>
>
> Uhm, need to know more about those. So i just print "`-[`", then 
> fully-qualified class name, then selector identifier, then "`]`"?


Instance methods get "-" and class methods (which are similar to static methods 
in Java) get the "+" prefix. See CGDebugInfo::getObjCMethodName() in 
CGDebugInfo.cpp for the gory details.


https://reviews.llvm.org/D22856



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


Re: [PATCH] D22874: [analyzer] Fixes to the checker developer manual.

2016-07-27 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

A couple of nits. Otherwise, LGTM. Thanks!



Comment at: www/analyzer/checker_dev_manual.html:534
@@ +533,3 @@
+itself to the child process (for example, in gcc you can
+set follow-fork-mode=child), or use the -###
+flag for obtaining the command line of the child process:

I suggest to just tell about -### and drop the explanation about attaching to 
the child process. Sounds good?


Comment at: www/analyzer/checker_dev_manual.html:645
@@ +644,3 @@
+
+The bug reporter mechanism removes path diagnostics inside intermediate
+function calls that have returned by the time the bug was found and contain

I'd move this up after the description of "-analyze-function=foo".


https://reviews.llvm.org/D22874



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


r276925 - Don't crash when generating code for __attribute__((naked)) member functions.

2016-07-27 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul 27 17:04:24 2016
New Revision: 276925

URL: http://llvm.org/viewvc/llvm-project?rev=276925&view=rev
Log:
Don't crash when generating code for __attribute__((naked)) member functions.

Summary:
Previously this crashed inside EmitThisParam().  There should be no
prelude for naked functions, so just skip the whole thing.

Reviewers: majnemer

Subscribers: llvm-commits

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

Added:
cfe/trunk/test/CodeGenCXX/naked.cpp
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=276925&r1=276924&r2=276925&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Jul 27 17:04:24 2016
@@ -1390,6 +1390,10 @@ void ItaniumCXXABI::addImplicitStructorP
 }
 
 void ItaniumCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) {
+  // Naked functions have no prolog.
+  if (CGF.CurFuncDecl && CGF.CurFuncDecl->hasAttr())
+return;
+
   /// Initialize the 'this' slot.
   EmitThisParam(CGF);
 

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=276925&r1=276924&r2=276925&view=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Jul 27 17:04:24 2016
@@ -1417,6 +1417,10 @@ llvm::Value *MicrosoftCXXABI::adjustThis
 }
 
 void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) {
+  // Naked functions have no prolog.
+  if (CGF.CurFuncDecl && CGF.CurFuncDecl->hasAttr())
+return;
+
   EmitThisParam(CGF);
 
   /// If this is a function that the ABI specifies returns 'this', initialize

Added: cfe/trunk/test/CodeGenCXX/naked.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/naked.cpp?rev=276925&view=auto
==
--- cfe/trunk/test/CodeGenCXX/naked.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/naked.cpp Wed Jul 27 17:04:24 2016
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows -emit-llvm %s -o - | FileCheck %s
+
+class TestNaked {
+public:
+  void NakedFunction();
+};
+
+__attribute__((naked)) void TestNaked::NakedFunction() {
+  // CHECK-LABEL: define void @
+  // CHECK: call void asm sideeffect
+  asm("");
+}


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


Re: [PATCH] D22788: [OpenMP] Code generation for the is_device_ptr clause

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65813.
sfantao updated the summary for this revision.
sfantao added a comment.

- Remove unecessary brief directives from comments.


https://reviews.llvm.org/D22788

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/OpenMPClause.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_is_device_ptr_codegen.cpp
  test/OpenMP/target_is_device_ptr_messages.cpp

Index: test/OpenMP/target_is_device_ptr_messages.cpp
===
--- test/OpenMP/target_is_device_ptr_messages.cpp
+++ test/OpenMP/target_is_device_ptr_messages.cpp
@@ -142,6 +142,7 @@
   T *&z = k;
   T aa[10];
   auto &raa = aa;
+  S6 *ps;
 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
   {}
 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
@@ -178,6 +179,22 @@
   {}
 #pragma omp target is_device_ptr(da) // OK
   {}
+#pragma omp target map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as firstprivate}}
+  {}
+#pragma omp target is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as private}}
+  {}
   return 0;
 }
 
@@ -194,6 +211,7 @@
   int *&z = k;
   int aa[10];
   auto &raa = aa;
+  S6 *ps;
 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
   {}
 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
@@ -230,5 +248,21 @@
   {}
 #pragma omp target is_device_ptr(da) // OK
   {}
+#pragma omp target map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as firstprivate}}
+  {}
+#pragma omp target is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as private}}
+  {}
   return tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: test/OpenMP/target_is_device_ptr_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -0,0 +1,293 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --

Re: [PATCH] D22691: [OpenMP] Codegen for use_device_ptr clause.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: lib/CodeGen/CGStmtOpenMP.cpp:3410-3411
@@ +3409,4 @@
+  llvm::DenseSet EmittedAsFirstprivate;
+  CGCapturedStmtInfo CapturesInfo(cast(*D.getAssociatedStmt()));
+  for (const auto *C : D.getClausesOfKind()) {
+auto OrigVarIt = C->varlist_begin();

ABataev wrote:
> EmitOMPUseDevicePtrClause() should emit the code for single clause. The outer 
> loop must be used in directive emission function.
Ok ,makes sense, Doing as you say.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:3477-3495
@@ +3476,21 @@
+  // Codegen with device pointer privatization.
+  auto &&PvtCodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+auto &&CodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+  OMPPrivateScope PrivateScope(CGF);
+  CGF.EmitOMPUseDevicePtrClause(S, PrivateScope, 
Info.CaptureDeviceAddrMap);
+  (void)PrivateScope.Privatize();
+  CGF.EmitStmt(
+  cast(S.getAssociatedStmt())->getCapturedStmt());
+};
+// Notwithstanding the body of the region is emitted as inlined directive,
+// we don't use an inline scope as changes in the references inside the
+// region are expected to be visible outside, so we do not privative them.
+OMPLexicalScope Scope(CGF, S);
+CGF.CGM.getOpenMPRuntime().emitInlinedDirective(CGF, OMPD_target_data,
+CodeGen);
+  };
+
+  // Codegen with no device pointer privatization.
+  auto &&NoPvtCodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+auto &&CodeGen = [&S, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
+  CGF.EmitStmt(

ABataev wrote:
> PvtCodeGen and NoPvtCodeGen are pretty similar. Could you merge them somehow 
> into the one? Maybe some custom PrePostAction could be used here?
I replaced this code by a single region codegen controlling the privatization 
with a flag and a pre-action. Let me know if this what you had in mind.


Comment at: lib/Sema/SemaOpenMP.cpp:11858
@@ +11857,3 @@
+// similar properties of a first private variable.
+DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_firstprivate, Ref);
+

ABataev wrote:
> Are the restrictions for firstprivates applied also? What if inner directive 
> has some clauses that cannot be used with variables previously marked as 
> firstprivates, but can be used with variables, used in use_device_ptr?
I was revisiting the spec and I couldn't find any conflict with the 
`firstprivate` restrictions. There are conflicts for variables used in a 
firstprivate clause that are also used in clauses of enclosing worksharing 
constructs but not the other way around. Note that we are using the 
firstprivate attribute but do not do all the firstprivate checks, so the 
conflicts would only arise from other enclosed constructs, not other enclosing 
constructs. Let me know if you have any specific case in mind or if you'd like 
me to do this differently.  


https://reviews.llvm.org/D22691



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


Re: [PATCH] D22691: [OpenMP] Codegen for use_device_ptr clause.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65810.
sfantao marked 8 inline comments as done.
sfantao added a comment.

- Remove unnecessary brief directives and refactor target data privatization 
code genenration.


https://reviews.llvm.org/D22691

Files:
  include/clang/AST/OpenMPClause.h
  lib/AST/OpenMPClause.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_codegen.cpp

Index: test/OpenMP/target_data_use_device_ptr_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_codegen.cpp
@@ -0,0 +1,464 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+///==///
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+double *g;
+
+// CK1: @g = global double*
+// CK1: [[MTYPE00:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE01:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE03:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE04:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE05:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE06:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE07:@.+]] = {{.*}}constant [1 x i32] [i32 99]
+// CK1: [[MTYPE08:@.+]] = {{.*}}constant [2 x i32] [{{i32 35, i32 99|i32 99, i32 35}}]
+// CK1: [[MTYPE09:@.+]] = {{.*}}constant [2 x i32] [i32 99, i32 99]
+// CK1: [[MTYPE10:@.+]] = {{.*}}constant [2 x i32] [i32 99, i32 99]
+// CK1: [[MTYPE11:@.+]] = {{.*}}constant [2 x i32] [i32 96, i32 35]
+// CK1: [[MTYPE12:@.+]] = {{.*}}constant [2 x i32] [i32 96, i32 35]
+
+// CK1-LABEL: @_Z3foo
+template
+void foo(float *&lr, T *&tr) {
+  float *l;
+  T *t;
+
+  // CK1-DAG: [[RVAL:%.+]] = bitcast double* [[T:%.+]] to i8*
+  // CK1-DAG: [[T]] = load double*, double** [[DECL:@g]],
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: store i8* [[RVAL]], i8** [[BP]],
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE00]]
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to double**
+  // CK1: [[VAL:%.+]] = load double*, double** [[CBP]],
+  // CK1-NOT: store double* [[VAL]], double** [[DECL]],
+  // CK1: store double* [[VAL]], double** [[PVT:%.+]],
+  // CK1: [[TT:%.+]] = load double*, double** [[PVT]],
+  // CK1: getelementptr inbounds double, double* [[TT]], i32 1
+  #pragma omp target data map(g[:10]) use_device_ptr(g)
+  {
+++g;
+  }
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE00]]
+  // CK1: [[TTT:%.+]] = load double*, double** [[DECL]],
+  // CK1: getelementptr inbounds double, double* [[TTT]], i32 1
+  ++g;
+
+  // CK1-DAG: [[RVAL:%.+]] = bitcast float* [[T1:%.+]] to i8*
+  // CK1-DAG: [[T1]] = load float*, float** [[DECL:%.+]],
+  // CK1: [[BP:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+  // CK1: store i8* [[RVAL]], i8** [[BP]],
+  // CK1: call void @__tgt_target_data_begin{{.+}}[[MTYPE01]]
+  // CK1: [[CBP:%.+]] = bitcast i8** [[BP]] to float**
+  // CK1: [[VAL:%.+]] = load float*, float** [[CBP]],
+  // CK1-NOT: store float* [[VAL]], float** [[DECL]],
+  // CK1: store float* [[VAL]], float** [[PVT:%.+]],
+  // CK1: [[TT1:%.+]] = load float*, float** [[PVT]],
+  // CK1: getelementptr inbounds float, float* [[TT1]], i32 1
+  #pragma omp target data map(l[:10]) use_device_ptr(l)
+  {
+++l;
+  }
+  // CK1: call void @__tgt_target_data_end{{.+}}[[MTYPE01]]
+  // CK1: [[TTT:%.+]] = load float*, float** [[DECL]],
+  // CK1: getelementptr inbounds float, float* [[TTT]], i32 1
+  ++l;
+
+  // CK1-NOT: call void @__tgt_targ

Re: [PATCH] D22766: Handle -mlong-calls on Hexagon

2016-07-27 Thread Eric Christopher via cfe-commits
echristo added a comment.

Go ahead and split out your cleanups into another patch and remove the custom 
handling in the hexagon target then.

Thanks!

-eric


Repository:
  rL LLVM

https://reviews.llvm.org/D22766



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


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Not a huge fan of the registration/etc. That said, this is cleaner than a lot 
of the alternatives at the moment without making you do a lot of toolchain 
evisceration.

LGTM.

-eric


https://reviews.llvm.org/D22596



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: test/CodeGenCUDA/kernel-args-alignment.cu:1-2
@@ +1,3 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+

rnk wrote:
> Typically clang doesn't need a registered backend for a target to generate IR 
> for that target. It "knows" a whole bunch of stuff about all target calling 
> conventions and data layout. Unless CUDA goes out of its way to query LLVM 
> backend information, we shouldn't need these REQUIRES lines.
> 
> You should probably test this theory, though, by configuring an ARM-only 
> clang and running the tests. :)
Yeah, I don't think we actually need this, as we have a bunch of other codegen 
tests that don't have these REQUIRES lines.


https://reviews.llvm.org/D22879



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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 65800.
jlebar added a comment.

Remove REQUIRES lines.


https://reviews.llvm.org/D22879

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/kernel-args-alignment.cu

Index: test/CodeGenCUDA/kernel-args-alignment.cu
===
--- /dev/null
+++ test/CodeGenCUDA/kernel-args-alignment.cu
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
+// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+
+#include "Inputs/cuda.h"
+
+struct U {
+  short x;
+} __attribute__((packed));
+
+struct S {
+  int *ptr;
+  char a;
+  U u;
+};
+
+// Clang should generate a packed LLVM struct for S (denoted by the <>s),
+// otherwise this test isn't interesting.
+// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+
+static_assert(alignof(S) == 8, "Unexpected alignment.");
+
+// HOST-LABEL: @_Z6kernelc1SPi
+// Marshalled kernel args should be:
+//   1. offset 0, width 1
+//   2. offset 8 (because alignof(S) == 8), width 16
+//   3. offset 24, width 8
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
+
+// DEVICE-LABEL: @_Z6kernelc1SPi
+// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+__global__ void kernel(char a, S s, int *b) {}
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -118,37 +118,28 @@
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction &CGF,
  FunctionArgList &Args) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
 llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero);
+llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
 CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock);
 CGF.EmitBlock(NextBlock);
+Offset += TyWidth;
   }
 
   // Emit the call to cudaLaunch
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -99,6 +99,12 @@
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(); I < NumArgs; ++I)
   ArgTypes.push_back(Args[I].RV.getScalarVal()->getType());
+
+// Using llvm::StructType is correct only because printf doesn't accept
+// aggregates.  If we had to handle aggregates here, we'd have to manually
+// compute the offsets within the alloca -- we wouldn't be able to assume
+// that the alignment of the llvm type was the same as the alignment of the
+// clang type.
 llvm::Type *AllocaTy = llvm::StructType::create(ArgTypes, "printf_arg

Re: r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Nirav Davé via cfe-commits
Looks like I missed the target triple. Should work now.

Thanks,

-Nirav

On Wed, Jul 27, 2016 at 4:41 PM, Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

> Hi Nirav,
>
> This test is failing on darwin:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26574
>
> Can you take a look?
>
> On Wed, Jul 27, 2016 at 12:57 PM, Nirav Dave via cfe-commits
>  wrote:
> > Author: niravd
> > Date: Wed Jul 27 14:57:40 2016
> > New Revision: 276907
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276907&view=rev
> > Log:
> > Add flags to toggle preservation of assembly comments
> >
> > Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.
> >
> > Reviewers: echristo, rnk
> >
> > Subscribers: mehdi_amini, llvm-commits
> >
> > Differential Revision: https://reviews.llvm.org/D22883
> >
> > Added:
> > cfe/trunk/test/CodeGen/preserve-as-comments.c
> > Modified:
> > cfe/trunk/include/clang/Driver/Options.td
> > cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> > cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > cfe/trunk/lib/Driver/Tools.cpp
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> >
> > Modified: cfe/trunk/include/clang/Driver/Options.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/Driver/Options.td (original)
> > +++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
> > @@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group >  def fno_pie : Flag<["-"], "fno-pie">, Group;
> >  def fplugin_EQ : Joined<["-"], "fplugin=">, Group,
> Flags<[DriverOption]>, MetaVarName<"">,
> >HelpText<"Load the named plugin (dynamic shared object)">;
> > +def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">,
> Group;
> > +def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">,
> Group, Flags<[CC1Option]>,
> > +  HelpText<"Do not preserve comments in inline assembly">;
> >  def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
> >  def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
> >  def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;
> >
> > Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> > +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27
> 14:57:40 2016
> > @@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
> >  CODEGENOPT(CompressDebugSections, 1, 0) ///<
> -Wa,-compress-debug-sections
> >  CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
> >  CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
> > +CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA,
> -fno-preserve-as-comments.
> >  CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit
> __attribute__((malloc)) operator new
> >  CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
> >  CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should
> be EH-safe.
> >
> > Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
> > @@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
> >CodeGenOpts.IncrementalLinkerCompatible;
> >Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
> >Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
> > +  Options.MCOptions.PreserveAsmComments =
> CodeGenOpts.PreserveAsmComments;
> >Options.MCOptions.ABIName = TargetOpts.ABI;
> >
> >TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
> FeaturesStr,
> >
> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> > +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
> > @@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation &C,
> >  true))
> >  CmdArgs.push_back("-fno-jump-tables");
> >
> > +  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
> > +options::OPT_fno_preserve_as_comments, true))
> > +CmdArgs.push_back("-fno-preserve-as-comments");
> > +
> >if (Arg *A = Args.getLastArg(options::OPT_m

r276915 - Add target triple in test

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 15:48:39 2016
New Revision: 276915

URL: http://llvm.org/viewvc/llvm-project?rev=276915&view=rev
Log:
Add target triple in test

Modified:
cfe/trunk/test/CodeGen/preserve-as-comments.c

Modified: cfe/trunk/test/CodeGen/preserve-as-comments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/preserve-as-comments.c?rev=276915&r1=276914&r2=276915&view=diff
==
--- cfe/trunk/test/CodeGen/preserve-as-comments.c (original)
+++ cfe/trunk/test/CodeGen/preserve-as-comments.c Wed Jul 27 15:48:39 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -S -fno-preserve-as-comments %s -o - | FileCheck %s 
--check-prefix=NOASM --check-prefix=CHECK
-// RUN: %clang_cc1 -S %s -o - | FileCheck %s --check-prefix=ASM 
--check-prefix=CHECK
+// RUN: %clang_cc1 -S -triple=x86_64-unknown-unknown -fno-preserve-as-comments 
%s -o - | FileCheck %s --check-prefix=NOASM --check-prefix=CHECK
+// RUN: %clang_cc1 -S %s -triple=x86_64-unknown-unknown -o - | FileCheck %s 
--check-prefix=ASM --check-prefix=CHECK
 
 // CHECK-LABEL: main
 // CHECK: #APP


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


Re: r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Bruno Cardoso Lopes via cfe-commits
Hi Nirav,

This test is failing on darwin:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26574

Can you take a look?

On Wed, Jul 27, 2016 at 12:57 PM, Nirav Dave via cfe-commits
 wrote:
> Author: niravd
> Date: Wed Jul 27 14:57:40 2016
> New Revision: 276907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276907&view=rev
> Log:
> Add flags to toggle preservation of assembly comments
>
> Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.
>
> Reviewers: echristo, rnk
>
> Subscribers: mehdi_amini, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D22883
>
> Added:
> cfe/trunk/test/CodeGen/preserve-as-comments.c
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907&r1=276906&r2=276907&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
> @@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group  def fno_pie : Flag<["-"], "fno-pie">, Group;
>  def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
> Flags<[DriverOption]>, MetaVarName<"">,
>HelpText<"Load the named plugin (dynamic shared object)">;
> +def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
> Group;
> +def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, 
> Group, Flags<[CC1Option]>,
> +  HelpText<"Do not preserve comments in inline assembly">;
>  def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
>  def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
>  def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907&r1=276906&r2=276907&view=diff
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27 14:57:40 
> 2016
> @@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
>  CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
>  CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
>  CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
> +CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
>  CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit 
> __attribute__((malloc)) operator new
>  CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
>  CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
> EH-safe.
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907&r1=276906&r2=276907&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
> @@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
>CodeGenOpts.IncrementalLinkerCompatible;
>Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
>Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
> +  Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
>Options.MCOptions.ABIName = TargetOpts.ABI;
>
>TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, 
> FeaturesStr,
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907&r1=276906&r2=276907&view=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
> @@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation &C,
>  true))
>  CmdArgs.push_back("-fno-jump-tables");
>
> +  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
> +options::OPT_fno_preserve_as_comments, true))
> +CmdArgs.push_back("-fno-preserve-as-comments");
> +
>if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
>  CmdArgs.push_back("-mregparm");
>  CmdArgs.push_back(A->getValue());
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=276907&r1=276906&r2=276907&view=diff
> ==

r276912 - test commit

2016-07-27 Thread Matt Masten via cfe-commits
Author: mmasten
Date: Wed Jul 27 15:23:32 2016
New Revision: 276912

URL: http://llvm.org/viewvc/llvm-project?rev=276912&view=rev
Log:
test commit

Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.h

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=276912&r1=276911&r2=276912&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Wed Jul 27 15:23:32 2016
@@ -55,6 +55,7 @@ public:
 Accelerate // Use the Accelerate framework.
   };
 
+
   enum ObjCDispatchMethodKind {
 Legacy = 0,
 NonLegacy = 1,


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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Vassil Vassilev via cfe-commits

Fixed in r276889 by Simon Pilgrim!
On 27/07/16 22:03, Vassil Vassilev wrote:

Looking into it.
On 27/07/16 18:34, Jun Bum Lim wrote:

junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: 
default label in switch which covers all enumeration values 
[-Werror,-Wcovered-switch-default]


   default: llvm_unreachable("Unknown code completion result Kind.");
   ^


Repository:
   rL LLVM

https://reviews.llvm.org/D17820







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


Re: r276889 - Fix unnecessary default switch warning

2016-07-27 Thread Vassil Vassilev via cfe-commits

Thanks a lot!
On 27/07/16 18:41, Simon Pilgrim via cfe-commits wrote:

Author: rksimon
Date: Wed Jul 27 11:41:56 2016
New Revision: 276889

URL: http://llvm.org/viewvc/llvm-project?rev=276889&view=rev
Log:
Fix unnecessary default switch warning

Modified:
 cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=276889&r1=276888&r2=276889&view=diff
==
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Jul 27 11:41:56 2016
@@ -445,8 +445,8 @@ bool PrintingCodeCompleteConsumer::isRes
case CodeCompletionResult::RK_Pattern: {
  return !StringRef(Result.Pattern->getAsString()).startswith(Filter);
}
-  default: llvm_unreachable("Unknown code completion result Kind.");
}
+  llvm_unreachable("Unknown code completion result Kind.");
  }
  
  void



___
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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 65796.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments. Added missing codegen test.


https://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,31 +1,85 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
-constant sampler_t glb_smp = 5;
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+
+constant sampler_t glb_smp4 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp5 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
+
+constant sampler_t glb_smp6 = glb_smp; // expected-error{{initializer element is not a compile-time constant}}
+
+int f(void);
+constant sampler_t glb_smp7 = f(); // expected-error{{initializer element is not a compile-time constant}}
+
+constant sampler_t glb_smp8 = 1.0f; // expected-error{{initializing '__constant sampler_t' with an expression of incompatible type 'float'}}
+
+constant sampler_t glb_smp9 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
 
 void foo(sampler_t);
 
 constant struct sampler_s {
   sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}
 } sampler_str = {0};
 
+sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
-  const sampler_t const_smp = 7;
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  const sampler_t const_smp2;
+  const sampler_t const_smp3 = const_smp;
+  const sampler_t const_smp4 = f();
+  const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const sampler_t' with an expression of incompatible type 'float'}}
+  const sampler_t const_smp6 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
+
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);
+  foo(glb_smp4);
+  foo(glb_smp5);
+  foo(glb_smp6);
+  foo(glb_smp7);
+  foo(glb_smp8);
+  foo(glb_smp9);
+  foo(smp);
+  foo(sampler_str.smp);
   foo(const_smp);
+  foo(const_smp2);
+  foo(const_smp3);
+  foo(const_smp4);
+  foo(const_smp5);
+  foo(const_smp6);
+  foo(argsmp);
   foo(5); // expected-error{{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
+  foo(sa[0]);
+  foo(bad());
 }
 
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
 
 void bar() {
-  sampler_t smp1 = 7;
-  sampler_t smp2 = 2;
+  sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
   smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}
   smp1+1; //expected-error{{invalid operands to binary expression ('s

Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Yaxun Liu via cfe-commits
yaxunl marked 9 inline comments as done.


Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:84
@@ +83,3 @@
+SamplerTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "__opencl_sampler_t"),
+  CGM.getContext().getTargetAddressSpace(

Anastasia wrote:
> Related to this thread: 
> http://lists.llvm.org/pipermail/cfe-dev/2016-July/050126.html.
> 
> I am guessing leaving the old naming scheme should be fine.
I have some more comments about that. I think we should use 
`struct.__opencl_sampler` as the name of sampler type in LLVM IR.


Comment at: lib/Sema/SemaInit.cpp:6949
@@ +6948,3 @@
+  // declaration.
+  if (!Var->getInit() || !isa(Var->getInit()))
+break;

Anastasia wrote:
> Do we accept declaring global sampler_t variable without an initializer?
no. Since in file scope sampler variable is only allowed in constant addr 
space, it has to be initialized. There is a test for it.


Comment at: lib/Sema/SemaInit.cpp:6956
@@ +6955,3 @@
+}
+  }
+

Anastasia wrote:
> Could you use else here instead of adding TakeLiteral variable to avoid going 
> to the next compound statement?
Good catch. Will do.


Comment at: lib/Sema/SemaInit.cpp:6965
@@ +6964,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

Anastasia wrote:
> Should this generate an error?
This has already been diagnosed when parsing the intializer of the variable 
declaration.


Comment at: test/SemaOpenCL/sampler_t.cl:51
@@ -14,1 +50,3 @@
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);

Anastasia wrote:
> Are these extra calls below adding any extra testing?
Add the function calls to test

1. No additional error msgs since the error msgs should be emitted for the 
variable declarations.
2. no crashes when parsing them


Comment at: test/SemaOpenCL/sampler_t.cl:83
@@ -28,2 +82,3 @@
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary 
expression}}
+  foo(smp1+1); //expected-error{{invalid operands to binary expression 
('sampler_t' and 'int')}}
 }

Anastasia wrote:
> Does this line add extra testing?
Test no crashes when an invalid sampler expression is passed as a sampler 
argument.


https://reviews.llvm.org/D21567



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


r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 14:57:40 2016
New Revision: 276907

URL: http://llvm.org/viewvc/llvm-project?rev=276907&view=rev
Log:
Add flags to toggle preservation of assembly comments

Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.

Reviewers: echristo, rnk

Subscribers: mehdi_amini, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/preserve-as-comments.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
@@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
+def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
Group;
+def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Do not preserve comments in inline assembly">;
 def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
 def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
 def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27 14:57:40 2016
@@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
 CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
 CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
@@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
   CodeGenOpts.IncrementalLinkerCompatible;
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+  Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
 
   TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
@@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation &C,
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
+options::OPT_fno_preserve_as_comments, true))
+CmdArgs.push_back("-fno-preserve-as-comments");
+
   if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
 CmdArgs.push_back("-mregparm");
 CmdArgs.push_back(A->getValue());

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=276907&r1=276906&r2=276907&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jul 27 14:57:40 2016
@@ -544,6 +544,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
   Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
   Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
+  Opts.PreserveAsmComme

Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Vassil Vassilev via cfe-commits

Looking into it.
On 27/07/16 18:34, Jun Bum Lim wrote:

junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: default label 
in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]

   default: llvm_unreachable("Unknown code completion result Kind.");
   ^


Repository:
   rL LLVM

https://reviews.llvm.org/D17820





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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Martin Storsjö via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D22857#497719, @rengolin wrote:

> I'll just echo @compnerd comments, since Phab didn't get it.
>
> - Change the syntax to __asm__, to be more portable
> - Add Microsoft asm block syntax


MSVC doesn't support inline assembly on ARM at all (they only support that on 
32 bit x86), so there's none of their syntax to support or test.

In https://reviews.llvm.org/D22857#497808, @rengolin wrote:

> As I read it, this is just making sure "inline asm" works on Windows, which 
> apparently hasn't been working so far. In a way, unrelated to the commit in 
> question.


No, inline assembly has been working, but only for assembly that didn't contain 
any immediate values.

> I agree we shouldn't be adding clang tests to assembler bugs.


Ok, we can skip this test if you prefer - the assembler test added for llvm-mc 
should be fine and enough as well.


https://reviews.llvm.org/D22857



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


r276904 - Adjust coercion of aggregates on RenderScript

2016-07-27 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Wed Jul 27 14:01:51 2016
New Revision: 276904

URL: http://llvm.org/viewvc/llvm-project?rev=276904&view=rev
Log:
Adjust coercion of aggregates on RenderScript

Summary:
In RenderScript, the size of the argument or return value emitted in the
IR is expected to be the same as the size of corresponding qualified
type.  For ARM and AArch64, the coercion performed by Clang can
change the parameter or return value to a type whose size is different
(usually larger) than the original aggregate type.  Specifically, this
can happen in the following cases:
- Aggregate parameters of size <= 64 bytes and return values smaller
  than 4 bytes on ARM
- Aggregate parameters and return values smaller than bytes on
  AArch64

This patch coerces the cases above to an integer array that is the same
size and alignment as the original aggregate.  A new field is added to
TargetInfo to detect a RenderScript target and limit this coercion just
to that case.

Tests added to test/CodeGen/renderscript.c

Reviewers: rsmith

Subscribers: aemerson, srhines, llvm-commits

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/renderscript.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Jul 27 14:01:51 2016
@@ -92,6 +92,8 @@ protected:
 
   unsigned HasBuiltinMSVaList : 1;
 
+  unsigned IsRenderScriptTarget : 1;
+
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple &T);
 
@@ -565,6 +567,9 @@ public:
   /// available on this target.
   bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; }
 
+  /// Returns true for RenderScript.
+  bool isRenderScriptTarget() const { return IsRenderScriptTarget; }
+
   /// \brief Returns whether the passed in string is a valid clobber in an
   /// inline asm statement.
   ///

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Wed Jul 27 14:01:51 2016
@@ -80,6 +80,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   SSERegParmMax = 0;
   HasAlignMac68kSupport = false;
   HasBuiltinMSVaList = false;
+  IsRenderScriptTarget = false;
 
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 27 14:01:51 2016
@@ -8113,6 +8113,7 @@ public:
  Triple.getOSName(),
  Triple.getEnvironmentName()),
 Opts) {
+IsRenderScriptTarget = true;
 LongWidth = LongAlign = 64;
   }
   void getTargetDefines(const LangOptions &Opts,
@@ -8130,7 +8131,9 @@ public:
   : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(),
  Triple.getOSName(),
  Triple.getEnvironmentName()),
-Opts) {}
+Opts) {
+IsRenderScriptTarget = true;
+  }
 
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=276904&r1=276903&r2=276904&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 27 14:01:51 2016
@@ -31,6 +31,31 @@
 using namespace clang;
 using namespace CodeGen;
 
+// Helper for coercing an aggregate argument or return value into an integer
+// array of the same size (including padding) and alignment.  This alternate
+// coercion happens only for the RenderScript ABI and can be removed after
+// runtimes that rely on it are no longer supported.
+//
+// RenderScript assumes that the size of the argument / return value in the IR
+// is the same as the size of the corresponding qualified type. This helper
+// coerces the aggregate type into an array of the same size (in

[PATCH] D22881: Fix NamedDeclFindingASTVisitor

2016-07-27 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added reviewers: klimek, omtcyfz.
alexshap added subscribers: compnerd, cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".

Properly initialize the field Context in NamedDeclFindingASTVisitor 
constructor: 
it is dereferenced in VisitTypeLoc Context->getLangOpts(). 
Fix passing nullptr to setResult in VisitTypeLoc: 
it is dereferenced in setResult Decl->getQualifiedNameAsString().
Add a test case: 
clang-rename crashes on it without this patch, works correctly with this patch. 
All the other tests are green.

https://reviews.llvm.org/D22881

Files:
  clang-rename/USRFinder.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp

Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -42,8 +42,9 @@
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const std::string &Name)
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string &Name,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -76,8 +77,9 @@
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@
 const NamedDecl *getNamedDeclFor(const ASTContext &Context,
  const std::string &Name) {
   const auto &SourceMgr = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, &Context);
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();


Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+
+void foo() {
+}
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -42,8 +42,9 @@
   // \brief Finds the NamedDecl for a name in the source.
   // \param Name the fully qualified name.
   explicit NamedDeclFindingASTVisitor(const SourceManager &SourceMgr,
-  const std::string &Name)
-  : Result(nullptr), SourceMgr(SourceMgr), Name(Name) {}
+  const std::string &Name,
+  const ASTContext *Context)
+  : Result(nullptr), SourceMgr(SourceMgr), Name(Name), Context(Context) {}
 
   // Declaration visitors:
 
@@ -76,8 +77,9 @@
 const auto TypeBeginLoc = Loc.getBeginLoc();
 const auto TypeEndLoc = Lexer::getLocForEndOfToken(
TypeBeginLoc, 0, SourceMgr, Context->getLangOpts());
-return setResult(Loc.getType()->getAsCXXRecordDecl(), TypeBeginLoc,
- TypeEndLoc);
+if (auto *RD = Loc.getType()->getAsCXXRecordDecl())
+  return setResult(RD, TypeBeginLoc, TypeEndLoc);
+return true;
   }
 
   // Other:
@@ -170,7 +172,7 @@
 const NamedDecl *getNamedDeclFor(const ASTContext &Context,
  const std::string &Name) {
   const auto &SourceMgr = Context.getSourceManager();
-  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name);
+  NamedDeclFindingASTVisitor Visitor(SourceMgr, Name, &Context);
   Visitor.TraverseDecl(Context.getTranslationUnitDecl());
 
   return Visitor.getNamedDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.or

Re: [PATCH] D21145: [Sema] Fix crash on valid where instantiation of lambda cannot access type of 'this'

2016-07-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276900: [Sema] Teach getCurrentThisType to reconize lambda 
in in-class initializer (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D21145?vs=60622&id=65779#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21145

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Index: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
===
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -961,32 +961,26 @@
 QualType Sema::getCurrentThisType() {
   DeclContext *DC = getFunctionLevelDeclContext();
   QualType ThisTy = CXXThisTypeOverride;
+
   if (CXXMethodDecl *method = dyn_cast(DC)) {
 if (method && method->isInstance())
   ThisTy = method->getThisType(Context);
   }
-  if (ThisTy.isNull()) {
-if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
-CurContext->getParent()->getParent()->isRecord()) {
-  // This is a generic lambda call operator that is being instantiated
-  // within a default initializer - so use the enclosing class as 'this'.
-  // There is no enclosing member function to retrieve the 'this' pointer
-  // from.
-
-  // FIXME: This looks wrong. If we're in a lambda within a lambda within a
-  // default member initializer, we need to recurse up more parents to find
-  // the right context. Looks like we should be walking up to the parent of
-  // the closure type, checking whether that is itself a lambda, and if so,
-  // recursing, until we reach a class or a function that isn't a lambda
-  // call operator. And we should accumulate the constness of *this on the
-  // way.
-
-  QualType ClassTy = Context.getTypeDeclType(
-  cast(CurContext->getParent()->getParent()));
-  // There are no cv-qualifiers for 'this' within default initializers, 
-  // per [expr.prim.general]p4.
-  ThisTy = Context.getPointerType(ClassTy);
-}
+
+  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
+  !ActiveTemplateInstantiations.empty()) {
+
+assert(isa(DC) &&
+   "Trying to get 'this' type from static method?");
+
+// This is a lambda call operator that is being instantiated as a default
+// initializer. DC must point to the enclosing class type, so we can 
recover
+// the 'this' type from it.
+
+QualType ClassTy = Context.getTypeDeclType(cast(DC));
+// There are no cv-qualifiers for 'this' within default initializers,
+// per [expr.prim.general]p4.
+ThisTy = Context.getPointerType(ClassTy);
   }
 
   // If we are within a lambda's call operator, the cv-qualifiers of 'this'


Index: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
===
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks %s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks %s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -961,32 +961,26 @@
 QualT

r276900 - [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

2016-07-27 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Jul 27 13:25:10 2016
New Revision: 276900

URL: http://llvm.org/viewvc/llvm-project?rev=276900&view=rev
Log:
[Sema] Teach getCurrentThisType to reconize lambda in in-class initializer

Fixes PR27994, a crash on valid.

Differential revision: https://reviews.llvm.org/D21145

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=276900&r1=276899&r2=276900&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jul 27 13:25:10 2016
@@ -961,32 +961,26 @@ static QualType adjustCVQualifiersForCXX
 QualType Sema::getCurrentThisType() {
   DeclContext *DC = getFunctionLevelDeclContext();
   QualType ThisTy = CXXThisTypeOverride;
+
   if (CXXMethodDecl *method = dyn_cast(DC)) {
 if (method && method->isInstance())
   ThisTy = method->getThisType(Context);
   }
-  if (ThisTy.isNull()) {
-if (isGenericLambdaCallOperatorSpecialization(CurContext) &&
-CurContext->getParent()->getParent()->isRecord()) {
-  // This is a generic lambda call operator that is being instantiated
-  // within a default initializer - so use the enclosing class as 'this'.
-  // There is no enclosing member function to retrieve the 'this' pointer
-  // from.
-
-  // FIXME: This looks wrong. If we're in a lambda within a lambda within a
-  // default member initializer, we need to recurse up more parents to find
-  // the right context. Looks like we should be walking up to the parent of
-  // the closure type, checking whether that is itself a lambda, and if so,
-  // recursing, until we reach a class or a function that isn't a lambda
-  // call operator. And we should accumulate the constness of *this on the
-  // way.
-
-  QualType ClassTy = Context.getTypeDeclType(
-  cast(CurContext->getParent()->getParent()));
-  // There are no cv-qualifiers for 'this' within default initializers, 
-  // per [expr.prim.general]p4.
-  ThisTy = Context.getPointerType(ClassTy);
-}
+
+  if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
+  !ActiveTemplateInstantiations.empty()) {
+
+assert(isa(DC) &&
+   "Trying to get 'this' type from static method?");
+
+// This is a lambda call operator that is being instantiated as a default
+// initializer. DC must point to the enclosing class type, so we can 
recover
+// the 'this' type from it.
+
+QualType ClassTy = Context.getTypeDeclType(cast(DC));
+// There are no cv-qualifiers for 'this' within default initializers,
+// per [expr.prim.general]p4.
+ThisTy = Context.getPointerType(ClassTy);
   }
 
   // If we are within a lambda's call operator, the cv-qualifiers of 'this'

Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=276900&r1=276899&r2=276900&view=diff
==
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Wed Jul 27 13:25:10 2016
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
-// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
 
 namespace std { class type_info; };
 
@@ -499,3 +498,30 @@ void foo() {
   };
 }
 }
+
+namespace PR27994 {
+struct A { template  A(T); };
+
+template 
+struct B {
+  int x;
+  A a = [&] { int y = x; };
+  A b = [&] { [&] { [&] { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; };
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+};
+
+B b;
+
+template  struct C {
+  struct D {
+int x;
+A f = [&] { int y = x; };
+  };
+};
+
+int func() {
+  C a;
+  decltype(a)::D b;
+}
+}


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


Re: [PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: test/CodeGenCUDA/kernel-args-alignment.cu:1-2
@@ +1,3 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+

Typically clang doesn't need a registered backend for a target to generate IR 
for that target. It "knows" a whole bunch of stuff about all target calling 
conventions and data layout. Unless CUDA goes out of its way to query LLVM 
backend information, we shouldn't need these REQUIRES lines.

You should probably test this theory, though, by configuring an ARM-only clang 
and running the tests. :)


https://reviews.llvm.org/D22879



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-27 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Btw, I am missing tests for generated __translate_sampler_initializer which I 
think we had at some point.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:84
@@ +83,3 @@
+SamplerTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "__opencl_sampler_t"),
+  CGM.getContext().getTargetAddressSpace(

Related to this thread: 
http://lists.llvm.org/pipermail/cfe-dev/2016-July/050126.html.

I am guessing leaving the old naming scheme should be fine.


Comment at: lib/Sema/SemaInit.cpp:6907
@@ -6905,2 +6906,3 @@
 case SK_OCLSamplerInit: {
-  assert(Step->Type->isSamplerT() && 
+  // Sampler initialzation have 6 cases:
+  //   1. function argument passing

There are 5 cases it seems :)


Comment at: lib/Sema/SemaInit.cpp:6947
@@ +6946,3 @@
+  // Do not diagnose if the file-scope variable does not have 
initializer
+  // since this has already beend diagnosed when parsing the variable
+  // declaration.

beend -> been


Comment at: lib/Sema/SemaInit.cpp:6949
@@ +6948,3 @@
+  // declaration.
+  if (!Var->getInit() || !isa(Var->getInit()))
+break;

Do we accept declaring global sampler_t variable without an initializer?


Comment at: lib/Sema/SemaInit.cpp:6956
@@ +6955,3 @@
+}
+  }
+

Could you use else here instead of adding TakeLiteral variable to avoid going 
to the next compound statement?


Comment at: lib/Sema/SemaInit.cpp:6965
@@ +6964,3 @@
+// the initializer.
+if (!Init->isConstantInitializer(S.Context, false))
+  break;

Should this generate an error?


Comment at: test/SemaOpenCL/sampler_t.cl:51
@@ -14,1 +50,3 @@
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);

Are these extra calls below adding any extra testing?


Comment at: test/SemaOpenCL/sampler_t.cl:83
@@ -28,2 +82,3 @@
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary 
expression}}
+  foo(smp1+1); //expected-error{{invalid operands to binary expression 
('sampler_t' and 'int')}}
 }

Does this line add extra testing?


https://reviews.llvm.org/D21567



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


Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-27 Thread Aaron En Ye Shi via cfe-commits
ashi1 updated this revision to Diff 65773.
ashi1 marked an inline comment as done.
ashi1 added a comment.

Removed indentation as per Anastasia's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D22637

Files:
  include/clang/Basic/OpenCLExtensions.def
  lib/Basic/Targets.cpp
  test/Misc/amdgcn.languageOptsOpenCL.cl
  test/SemaOpenCL/extension-version.cl

Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -222,6 +222,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 
 #if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
+#if (__OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -181,6 +181,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_egl_image' - 
ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
 #ifdef cl_khr_srgb_image_writes
 #error "Incorrect cl_khr_srgb_image_writes define"
 #endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2115,6 +2115,7 @@
   Opts.cl_khr_fp16 = 1;
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
+  Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }
Index: include/clang/Basic/OpenCLExtensions.def
===
--- include/clang/Basic/OpenCLExtensions.def
+++ include/clang/Basic/OpenCLExtensions.def
@@ -67,6 +67,7 @@
 // OpenCL 2.0.
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)


Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -222,6 +222,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 
 #if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
+#if (__OPENCL_C_VERSION__ >= 200)
 #ifndef cl_khr_srgb_image_writes
 #error "Missing cl_khr_srgb_image_writes define"
 #endif
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -181,6 +181,18 @@
 #pragma OPENCL EXTENSION cl_khr_egl_image: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_egl_image' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_mipmap_image
+#error "Missing cl_khr_mipmap_image define"
+#endif
+#else
+#ifdef cl_khr_mipmap_image
+#error "Incorrect cl_khr_mipmap_image define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable
+
 #ifdef cl_khr_srgb_image_writes
 #error "Incorrect cl_khr_srgb_image_writes define"
 #endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2115,6 +2115,7 @@
   Opts.cl_khr_fp16 = 1;
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
+  Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }
Index: include/clang/Basic/OpenCLExtensions.def
===
--- include/clang/Basic/OpenCLExtensions.def
+++ include/clang/Basic

r276896 - Update Clang Parser test error message to match new parser errors

2016-07-27 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Wed Jul 27 12:39:47 2016
New Revision: 276896

URL: http://llvm.org/viewvc/llvm-project?rev=276896&view=rev
Log:
Update Clang Parser test error message to match new parser errors

Modified:
cfe/trunk/test/Parser/ms-inline-asm.c

Modified: cfe/trunk/test/Parser/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-inline-asm.c?rev=276896&r1=276895&r2=276896&view=diff
==
--- cfe/trunk/test/Parser/ms-inline-asm.c (original)
+++ cfe/trunk/test/Parser/ms-inline-asm.c Wed Jul 27 12:39:47 2016
@@ -54,7 +54,7 @@ void t12() {
   __asm jmp label // expected-error {{use of undeclared label 'label'}}
 }
 void t13() {
-  __asm m{o}v eax, ebx // expected-error {{expected identifier}} 
expected-error {{use of undeclared label '{o}v eax, ebx'}}
+  __asm m{o}v eax, ebx // expected-error {{unknown token in expression}}
 }
 
 int t_fail() { // expected-note {{to match this}}


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


[PATCH] D22879: [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.

2016-07-27 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added subscribers: tra, cfe-commits.

Before this patch, we computed the offsets in memory of args passed to
GPU kernel functions by throwing all of the args into an LLVM struct.

clang emits packed llvm structs basically whenever it feels like it, and
packed structs have alignment 1.  So we cannot rely on the llvm type's
alignment matching the C++ type's alignment.

This patch fixes our codegen so we always respect the clang types'
alignments.

https://reviews.llvm.org/D22879

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/kernel-args-alignment.cu

Index: test/CodeGenCUDA/kernel-args-alignment.cu
===
--- /dev/null
+++ test/CodeGenCUDA/kernel-args-alignment.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
+// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+
+#include "Inputs/cuda.h"
+
+struct U {
+  short x;
+} __attribute__((packed));
+
+struct S {
+  int *ptr;
+  char a;
+  U u;
+};
+
+// Clang should generate a packed LLVM struct for S (denoted by the <>s),
+// otherwise this test isn't interesting.
+// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+
+static_assert(alignof(S) == 8, "Unexpected alignment.");
+
+// HOST-LABEL: @_Z6kernelc1SPi
+// Marshalled kernel args should be:
+//   1. offset 0, width 1
+//   2. offset 8 (because alignof(S) == 8), width 16
+//   3. offset 24, width 8
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8)
+// HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
+
+// DEVICE-LABEL: @_Z6kernelc1SPi
+// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+__global__ void kernel(char a, S s, int *b) {}
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -118,37 +118,28 @@
 
 void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction &CGF,
  FunctionArgList &Args) {
-  // Build the argument value list and the argument stack struct type.
-  SmallVector ArgValues;
-  std::vector ArgTypes;
-  for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
-   I != E; ++I) {
-llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer();
-ArgValues.push_back(V);
-assert(isa(V->getType()) && "Arg type not PointerType");
-ArgTypes.push_back(cast(V->getType())->getElementType());
-  }
-  llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes);
-
-  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
-
-  // Emit the calls to cudaSetupArgument
+  // Emit a call to cudaSetupArgument for each arg in Args.
   llvm::Constant *cudaSetupArgFn = getSetupArgumentFn();
-  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
-llvm::Value *Args[3];
-llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
-Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy);
-Args[1] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getSizeOf(ArgTypes[I]),
-SizeTy, false);
-Args[2] = CGF.Builder.CreateIntCast(
-llvm::ConstantExpr::getOffsetOf(ArgStackTy, I),
-SizeTy, false);
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+  CharUnits Offset = CharUnits::Zero();
+  for (const VarDecl *A : Args) {
+CharUnits TyWidth, TyAlign;
+std::tie(TyWidth, TyAlign) =
+CGM.getContext().getTypeInfoInChars(A->getType());
+Offset = Offset.alignTo(TyAlign);
+llvm::Value *Args[] = {
+CGF.Builder.CreatePointerCast(CGF.GetAddrOfLocalVar(A).getPointer(),
+  VoidPtrTy),
+llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
+llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
+};
 llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
 llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero);
+llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next");
 CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock);
 CGF.EmitBlock(NextBlock);
+Offset += TyWidth;
   }
 
   // Emit the call to cudaLaunch
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -99,6 +99,12 @@
 llvm::SmallVector ArgTypes;
 for (unsigned I = 1, NumArgs = Args.size(

Re: [PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi updated this revision to Diff 65765.
ibadawi added a comment.

Restore the test lost in patch #2. Really sorry for the noise...


https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi updated this revision to Diff 65763.
ibadawi added a comment.

Remove extra blank line added by accident


https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,9 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22874: [analyzer] Fixes to the checker developer manual.

2016-07-27 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added a reviewer: zaks.anna.
NoQ added subscribers: dcoughlin, xazax.hun, a.sidorin, cfe-commits.

1. Fix the explanation of how to run tests after migration from autotools to 
cmake.

2. Expand the "debugging" section with more interesting stuff, as accidentally 
discussed in D22622 and D22856.

Any other things to fix there?

Also, does anybody think it's a good idea to mention my unofficial guide 
(https://github.com/haoNoQ/clang-analyzer-guide/releases) in the "additional 
sources" section?

https://reviews.llvm.org/D22874

Files:
  www/analyzer/checker_dev_manual.html

Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -511,75 +511,143 @@
   live in clang/test/Analysis folder. To run all of the analyzer tests, 
   execute the following from the clang build directory:
 
-$ TESTDIRS=Analysis make test
+$ bin/llvm-lit -sv ../llvm/tools/clang/test/Analysis
 
 
 Useful Commands/Debugging Hints
-
-
-While investigating a checker-related issue, instruct the analyzer to only 
+
+Attaching the debugger
+
+When your command contains the -cc1 flag, you can attach the
+debugger to it directly:
+
+
+$ gdb --args clang -cc1 -analyze -analyzer-checker=core test.c
+$ lldb -- clang -cc1 -analyze -analyzer-checker=core test.c
+
+
+
+Otherwise, if your command line contains --analyze,
+the actual clang instance would be run in a separate process. In
+order to debug it, you'd have to either instruct your debugger to attach
+itself to the child process (for example, in gcc you can
+set follow-fork-mode=child), or use the -###
+flag for obtaining the command line of the child process:
+
+
+
+$ clang --analyze test.c -\#\#\#
+
+
+
+Below we describe a few useful command line arguments, all of which assume that
+you are running clang -cc1.
+
+
+Narrowing down the problem
+
+While investigating a checker-related issue, instruct the analyzer to only
 execute a single checker:
-
-$ clang -cc1 -analyze -analyzer-checker=osx.KeychainAPI test.c
-
-
-
-To dump AST:
-
-$ clang -cc1 -ast-dump test.c
-
-
-
-To view/dump CFG use debug.ViewCFG or debug.DumpCFG checkers:
-
-$ clang -cc1 -analyze -analyzer-checker=debug.ViewCFG test.c
- 
-
-
-To see all available debug checkers:
-
-$ clang -cc1 -analyzer-checker-help | grep "debug"
-
-
-
-To see which function is failing while processing a large file use 
--analyzer-display-progress option.
-
-
-While debugging execute clang -cc1 -analyze -analyzer-checker=core 
-instead of clang --analyze, as the later would call the compiler 
-in a separate process.
-
-
-To view ExplodedGraph (the state graph explored by the analyzer) while 
-debugging, goto a frame that has clang::ento::ExprEngine object and 
-execute:
- 
-(gdb) p ViewGraph(0)
-
-
-
-To see the ProgramState while debugging use the following command. 
-
-(gdb) p State->dump()
- 
-
-
-To see clang::Expr while debugging use the following command. If you 
-pass in a SourceManager object, it will also dump the corresponding line in the 
-source code.
-
-(gdb) p E->dump()
- 
-
-
-To dump AST of a method that the current ExplodedNode belongs to:
-
-(gdb) p C.getPredecessor()->getCodeDecl().getBody()->dump()
-(gdb) p C.getPredecessor()->getCodeDecl().getBody()->dump(getContext().getSourceManager())
-
-
-
+
+
+$ clang -cc1 -analyze -analyzer-checker=osx.KeychainAPI test.c
+
+
+If you are experiencing a crash, to see which function is failing while
+processing a large file use the  -analyzer-display-progress
+option.
+
+You can analyze a particular function within the file, which is often useful
+because the problem is always in a certain function:
+
+$ clang -cc1 -analyze -analyzer-checker=core test.c -analyzer-display-progress
+ANALYZE (Syntax): test.c foo
+ANALYZE (Syntax): test.c bar
+ANALYZE (Path,  Inline_Regular): test.c bar
+ANALYZE (Path,  Inline_Regular): test.c foo
+$ clang -cc1 -analyze -analyzer-checker=core test.c -analyzer-display-progress -analyze-function=foo
+ANALYZE (Syntax): test.c foo
+ANALYZE (Path,  Inline_Regular): test.c foo
+
+
+Visualizing the analysis
+
+To dump the AST, which often helps understanding how the program should
+behave:
+
+$ clang -cc1 -ast-dump test.c
+
+
+To view/dump CFG use debug.ViewCFG or debug.DumpCFG
+checkers:
+
+$ clang -cc1 -analyze -analyzer-checker=debug.ViewCFG test.c
+
+
+ExplodedGraph (the state graph explored by the analyzer) can be
+visualized with another debug checker:
+
+$ clang -cc1 -analyze -analyzer-checker=debug.ViewExplodedGraph test.c
+
+Or, equivalently, with -analyzer-viz-egraph-graphviz
+option, which does the same thing - dumps the exploded graph in graphviz
+.dot format.
+
+You can convert .dot files into other formats - in
+particular, converting to .svg and viewing in your web
+browser might be more comfortable than using 

r276891 - UsersManual.rst: update clang-cl option list

2016-07-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 27 11:56:03 2016
New Revision: 276891

URL: http://llvm.org/viewvc/llvm-project?rev=276891&view=rev
Log:
UsersManual.rst: update clang-cl option list

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=276891&r1=276890&r2=276891&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Jul 27 11:56:03 2016
@@ -2118,16 +2118,26 @@ Execute ``clang-cl /?`` to see a list of
   /fp:fast
   /fp:precise
   /fp:strict
+  /Fp  Set pch filename (with /Yc and /Yu)
   /GAAssume thread-local variables are defined in the 
executable
+  /GdSet __cdecl as a default calling convention
   /GF-   Disable string pooling
   /GR-   Disable emission of RTTI data
   /GREnable emission of RTTI data
+  /GrSet __fastcall as a default calling convention
+  /GS-   Disable buffer security check
+  /GSEnable buffer security check
   /Gs Set stack probe size
+  /GvSet __vectorcall as a default calling convention
   /Gw-   Don't put each data item in its own section
   /GwPut each data item in its own section
+  /GX-   Enable exception handling
+  /GXEnable exception handling
   /Gy-   Don't put each function in its own section
   /GyPut each function in its own section
+  /GzSet __stdcall as a default calling convention
   /help  Display available options
+  /imsvcAdd directory to system include search path, as 
if part of %INCLUDE%
   /IAdd directory to include search path
   /J Make char type unsigned
   /LDd   Create debug DLL
@@ -2137,7 +2147,6 @@ Execute ``clang-cl /?`` to see a list of
   /MDUse DLL run-time
   /MTd   Use static debug run-time
   /MTUse static run-time
-  /Ob0   Disable inlining
   /OdDisable optimization
   /Oi-   Disable use of builtin functions
   /OiEnable use of builtin functions
@@ -2149,6 +2158,7 @@ Execute ``clang-cl /?`` to see a list of
   /Qvec- Disable the loop vectorization passes
   /Qvec  Enable the loop vectorization passes
   /showIncludes  Print info about included files to stderr
+  /std:   Language standard to compile for
   /TCTreat all source files as C
   /Tc  Specify a C source file
   /TPTreat all source files as C++
@@ -2171,6 +2181,9 @@ Execute ``clang-cl /?`` to see a list of
   /WX-   Do not treat warnings as errors
   /WXTreat warnings as errors
   /w Disable all warnings
+  /Y-Disable precompiled headers, overrides /Yc and /Yu
+  /Yc  Generate a pch file for all code up to and 
including 
+  /Yu  Load a pch file and use it instead of all code up 
to and including 
   /Z7Enable CodeView debug information in object files
   /Zc:sizedDealloc-  Disable C++14 sized global deallocation functions
   /Zc:sizedDealloc   Enable C++14 sized global deallocation functions
@@ -2179,6 +2192,7 @@ Execute ``clang-cl /?`` to see a list of
   /Zc:threadSafeInit Enable thread-safe initialization of static 
variables
   /Zc:trigraphs- Disable trigraphs (default)
   /Zc:trigraphs  Enable trigraphs
+  /ZdEmit debug line number tables only
   /ZiAlias for /Z7. Does not produce PDBs.
   /ZlDon't mention any default libraries in the object 
file
   /ZpSet the default maximum struct packing alignment 
to 1
@@ -2215,6 +2229,8 @@ Execute ``clang-cl /?`` to see a list of
   -fsanitize=  Turn on runtime checks for various forms of 
undefined or suspicious
   behavior. See user manual for available checks
   -gcodeview  Generate CodeView debug information
+  -gline-tables-only  Emit debug line number tables only
+  -miamcu Use Intel MCU ABI
   -mllvm   Additional arguments to forward to LLVM's option 
processing
   -Qunused-arguments  Don't emit warning for unused driver arguments
   -R  Enable the specified

Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-27 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Misc/amdgcn.languageOptsOpenCL.cl:188
@@ +187,3 @@
+  #endif
+#else
+  #ifdef cl_khr_mipmap_image

Looks good! Could you just remove indentation please as it's not common for C 
macros?

The same for the test below!


Repository:
  rL LLVM

https://reviews.llvm.org/D22637



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


Re: [PATCH] D22518: Refactor how include paths are appended to the command arguments.

2016-07-27 Thread Artem Belevich via cfe-commits
tra added a comment.

Looks good.


https://reviews.llvm.org/D22518



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


r276889 - Fix unnecessary default switch warning

2016-07-27 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Jul 27 11:41:56 2016
New Revision: 276889

URL: http://llvm.org/viewvc/llvm-project?rev=276889&view=rev
Log:
Fix unnecessary default switch warning

Modified:
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=276889&r1=276888&r2=276889&view=diff
==
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Jul 27 11:41:56 2016
@@ -445,8 +445,8 @@ bool PrintingCodeCompleteConsumer::isRes
   case CodeCompletionResult::RK_Pattern: {
 return !StringRef(Result.Pattern->getAsString()).startswith(Filter);
   }
-  default: llvm_unreachable("Unknown code completion result Kind.");
   }
+  llvm_unreachable("Unknown code completion result Kind.");
 }
 
 void 


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


r276887 - Update cxx_dr_Status after 3.9 branch

2016-07-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jul 27 11:39:45 2016
New Revision: 276887

URL: http://llvm.org/viewvc/llvm-project?rev=276887&view=rev
Log:
Update cxx_dr_Status after 3.9 branch

Modified:
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=276887&r1=276886&r2=276887&view=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Wed Jul 27 11:39:45 2016
@@ -7315,7 +7315,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1250";>1250
 CD3
 Cv-qualification of incomplete virtual function return types
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1251";>1251
@@ -9253,7 +9253,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1573";>1573
 DRWP
 Inherited constructor characteristics
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1574";>1574
@@ -9289,7 +9289,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579";>1579
 C++14
 Return by converting move constructor
-Unknown
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1580";>1580
@@ -9685,7 +9685,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1645";>1645
 DR
 Identical inheriting constructors via default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1646";>1646
@@ -10105,7 +10105,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1715";>1715
 DR
 Access and inherited constructor templates
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1716";>1716
@@ -10231,7 +10231,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1736";>1736
 DR
 Inheriting constructor templates in a local class
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1737";>1737
@@ -11461,7 +11461,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1941";>1941
 DR
 SFINAE and inherited constructor default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1942";>1942
@@ -11569,7 +11569,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1959";>1959
 DR
 Inadvertently inherited copy constructor
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1960";>1960
@@ -11761,7 +11761,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1991";>1991
 DR
 Inheriting constructors vs default arguments
-SVN
+Clang 3.9
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1992";>1992

Modified: cfe/trunk/www/make_cxx_dr_status
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/make_cxx_dr_status?rev=276887&r1=276886&r2=276887&view=diff
==
--- cfe/trunk/www/make_cxx_dr_status (original)
+++ cfe/trunk/www/make_cxx_dr_status Wed Jul 27 11:39:45 2016
@@ -102,10 +102,10 @@ def availability(issue):
   if status == 'unknown':
 avail = 'Unknown'
 avail_style = ' class="none"'
-  elif status == '3.9':
+  elif status == '4.0':
 avail = 'SVN'
 avail_style = ' class="svn"'
-  elif status.startswith('3.'):
+  elif re.match('^[0-9]+\.', status):
 avail = 'Clang %s' % status
 avail_style = ' class="full"'
   elif status == 'yes':


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


Re: [PATCH] D22596: Retry: [Driver] Compute effective target triples once per job (NFCI)

2016-07-27 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Ping.


https://reviews.llvm.org/D22596



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


[PATCH] D22871: Fix incorrect -Wtautological-constant-out-of-range warnings with enums

2016-07-27 Thread Ismail Badawi via cfe-commits
ibadawi created this revision.
ibadawi added reviewers: majnemer, rjmccall.
ibadawi added a subscriber: cfe-commits.

This is a proposed fix for bug 16154 
(https://llvm.org/bugs/show_bug.cgi?id=16154) -- it was tentatively fixed in 
r183084 but had the fix was backed out in r183575 because the approach taken 
wrongly affected the behavior or other warnings.

https://reviews.llvm.org/D22871

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+
T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,10 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
+
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();


Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -147,3 +147,15 @@
 
 return 1;
 }
+
+typedef enum {
+  alpha = 0,
+  bravo,
+  charlie,
+  delta,
+  echo
+} named_t;
+
+static int bar(named_t foo) {
+  return foo > 42;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -7075,6 +7075,12 @@
 return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger());
   }
 
+  /// Returns the "target" range of a given integral type.
+  static IntRange forTargetOfType(ASTContext &C, QualType T) {
+return forTargetOfCanonicalType(C,
+T->getCanonicalTypeInternal().getTypePtr());
+  }
+
   /// Returns the "target" range of a canonical integral type, i.e.
   /// the range of values expressible in the type.
   ///
@@ -7492,7 +7498,10 @@
   QualType OtherT = Other->getType();
   if (const auto *AT = OtherT->getAs())
 OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
+  IntRange OtherRange = S.getLangOpts().CPlusPlus
+? IntRange::forValueOfType(S.Context, OtherT)
+: IntRange::forTargetOfType(S.Context, OtherT);
+
   unsigned OtherWidth = OtherRange.Width;
 
   bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-27 Thread Jun Bum Lim via cfe-commits
junbuml added a subscriber: junbuml.
junbuml added a comment.

It appears that build fails due to this change :

llvm/tools/clang/lib/Sema/CodeCompleteConsumer.cpp:448:3: error: default label 
in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]

  default: llvm_unreachable("Unknown code completion result Kind.");
  ^


Repository:
  rL LLVM

https://reviews.llvm.org/D17820



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Renato Golin via cfe-commits
rengolin added a comment.

In https://reviews.llvm.org/D22857#497805, @ahatanak wrote:

> Is r276859 fixing a bug in the assembler?


Sort of. It was just adding a comment character to ; instead of #.

> I'm trying to understand why we have to add a clang test in this particular 
> case because I don't think we normally add a test in clang every time we fix 
> a bug in the backend or assembler.


As I read it, this is just making sure "inline asm" works on Windows, which 
apparently hasn't been working so far. In a way, unrelated to the commit in 
question.

I agree we shouldn't be adding clang tests to assembler bugs.


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22857: [ARM] Add a test for inline assembly when targeting armv7-windows

2016-07-27 Thread Akira Hatanaka via cfe-commits
ahatanak added a subscriber: ahatanak.
ahatanak added a comment.

Is r276859 fixing a bug in the assembler?

I'm trying to understand why we have to add a clang test in this particular 
case because I don't think we normally add a test in clang every time we fix a 
bug in the backend or assembler.


https://reviews.llvm.org/D22857



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


Re: [PATCH] D22690: [OpenMP] Add support for mapping array sections through pointer references.

2016-07-27 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 65751.
sfantao marked an inline comment as done.
sfantao added a comment.

- Use castAs instead of getAs in pointer type.


https://reviews.llvm.org/D22690

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp

Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -60,12 +60,15 @@
 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK2 --check-prefix CK2-32
 #ifdef CK2
 
-// CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
+// CK2: [[SIZES:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
 // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_IS_FIRST = 288
-// CK2-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[TYPES:@.+]] = {{.+}}constant [1 x i32] [i32 288]
+// CK2: [[SIZES2:@.+]] = {{.+}}constant [1 x i[[sz]]] zeroinitializer
+// Map types: OMP_MAP_IS_PTR = 32
+// CK2: [[TYPES2:@.+]] = {{.+}}constant [1 x i32] [i32 32]
 
-// CK2-LABEL: implicit_maps_integer_reference
-void implicit_maps_integer_reference (int a){
+// CK2-LABEL: implicit_maps_reference
+void implicit_maps_reference (int a, int *b){
   int &i = a;
   // CK2-DAG: call i32 @__tgt_target(i32 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, {{.+}}[[TYPES]]{{.+}})
   // CK2-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
@@ -85,6 +88,25 @@
   {
++i;
   }
+
+  int *&p = b;
+  // CK2-DAG: call i32 @__tgt_target(i32 {{.+}}, i8* {{.+}}, i32 1, i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES2]]{{.+}}, {{.+}}[[TYPES2]]{{.+}})
+  // CK2-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, i32 0
+  // CK2-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, i32 0
+  // CK2-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK2-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK2-DAG: store i8* [[VALBP:%.+]], i8** [[BP1]],
+  // CK2-DAG: store i8* [[VALP:%.+]], i8** [[P1]],
+  // CK2-DAG: [[VALBP]] = bitcast i32* [[VAL:%.+]] to i8*
+  // CK2-DAG: [[VALP]] = bitcast i32* [[VAL]] to i8*
+  // CK2-DAG: [[VAL]] = load i32*, i32** [[ADDR:%.+]],
+  // CK2-DAG: [[ADDR]] = load i32**, i32*** [[ADDR2:%.+]],
+
+  // CK2: call void [[KERNEL2:@.+]](i32* [[VAL]])
+  #pragma omp target
+  {
+   ++p;
+  }
 }
 
 // CK2: define internal void [[KERNEL]](i[[sz]] [[ARG:%.+]])
@@ -99,6 +121,14 @@
 // CK2-32: [[RVAL:%.+]] = load i32*, i32** [[REF]],
 // CK2-32: {{.+}} = load i32, i32* [[RVAL]],
 
+// CK2: define internal void [[KERNEL2]](i32* [[ARG:%.+]])
+// CK2: [[ADDR:%.+]] = alloca i32*,
+// CK2: [[REF:%.+]] = alloca i32**,
+// CK2: store i32* [[ARG]], i32** [[ADDR]],
+// CK2: store i32** [[ADDR]], i32*** [[REF]],
+// CK2: [[T:%.+]] = load i32**, i32*** [[REF]],
+// CK2: [[TT:%.+]] = load i32*, i32** [[T]],
+// CK2: getelementptr inbounds i32, i32* [[TT]], i32 1
 #endif
 ///==///
 // RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK3 --check-prefix CK3-64
@@ -4471,4 +4501,67 @@
 // CK27: define {{.+}}[[CALL06]]
 // CK27: define {{.+}}[[CALL07]]
 #endif
+///==///
+// RUN: %clang_cc1 -DCK28 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK28 --check-prefix CK28-64
+// RUN: %clang_cc1 -DCK28 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-64
+// RUN: %clang_cc1 -DCK28 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-32
+// RUN: %clang_cc1 -DCK28 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK28 --check-prefix CK28-32
+#ifdef CK28
+
+// CK28: [[SIZE00:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] [i[[Z:64|32]] {{8|4}}]
+// CK28: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i32] 

  1   2   >