Re: [PATCH] D10137: On {mips, mipsel, mips64, mips64el}-freebsd, we need to pass any -G option to the assembler.

2015-12-27 Thread Dimitry Andric via cfe-commits
dim updated this revision to Diff 43655.
dim added a comment.

Add a test for passing -G0 to the assembler.


http://reviews.llvm.org/D10137

Files:
  lib/Driver/Tools.cpp
  test/Driver/freebsd-mips-as.c

Index: test/Driver/freebsd-mips-as.c
===
--- test/Driver/freebsd-mips-as.c
+++ test/Driver/freebsd-mips-as.c
@@ -89,3 +89,9 @@
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2 %s
 // MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+//
+// RUN: %clang -target mips-unknown-freebsd -### \
+// RUN:   -no-integrated-as -G0 -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS32-EB-AS-G0 %s
+// MIPS32-EB-AS-G0: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-G0"
+// MIPS32-EB-AS-G0-NOT: "-KPIC"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7776,6 +7776,12 @@
 else
   CmdArgs.push_back("-EL");
 
+if (Arg *A = Args.getLastArg(options::OPT_G)) {
+  StringRef v = A->getValue();
+  CmdArgs.push_back(Args.MakeArgString("-G" + v));
+  A->claim();
+}
+
 AddAssemblerKPIC(getToolChain(), Args, CmdArgs);
 break;
   }


Index: test/Driver/freebsd-mips-as.c
===
--- test/Driver/freebsd-mips-as.c
+++ test/Driver/freebsd-mips-as.c
@@ -89,3 +89,9 @@
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2 %s
 // MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+//
+// RUN: %clang -target mips-unknown-freebsd -### \
+// RUN:   -no-integrated-as -G0 -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS32-EB-AS-G0 %s
+// MIPS32-EB-AS-G0: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-G0"
+// MIPS32-EB-AS-G0-NOT: "-KPIC"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7776,6 +7776,12 @@
 else
   CmdArgs.push_back("-EL");
 
+if (Arg *A = Args.getLastArg(options::OPT_G)) {
+  StringRef v = A->getValue();
+  CmdArgs.push_back(Args.MakeArgString("-G" + v));
+  A->claim();
+}
+
 AddAssemblerKPIC(getToolChain(), Args, CmdArgs);
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r256468 - On {mips, mipsel, mips64, mips64el}-freebsd, we need to pass any -G option to the assembler.

2015-12-27 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Sun Dec 27 04:36:44 2015
New Revision: 256468

URL: http://llvm.org/viewvc/llvm-project?rev=256468=rev
Log:
On {mips,mipsel,mips64,mips64el}-freebsd, we need to pass any -G option to the 
assembler.

Summary:
See also:
https://sourceware.org/binutils/docs/as/MIPS-Options.html#index-g_t_0040code_007b_002dG_007d-option-_0028MIPS_0029-1392

Reviewers: theraven, atanasyan, brooks, emaste

Subscribers: rnk, emaste, cfe-commits, seanbruno, dim

Differential Revision: http://reviews.llvm.org/D10137

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/freebsd-mips-as.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256468=256467=256468=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Dec 27 04:36:44 2015
@@ -7776,6 +7776,12 @@ void freebsd::Assembler::ConstructJob(Co
 else
   CmdArgs.push_back("-EL");
 
+if (Arg *A = Args.getLastArg(options::OPT_G)) {
+  StringRef v = A->getValue();
+  CmdArgs.push_back(Args.MakeArgString("-G" + v));
+  A->claim();
+}
+
 AddAssemblerKPIC(getToolChain(), Args, CmdArgs);
 break;
   }

Modified: cfe/trunk/test/Driver/freebsd-mips-as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd-mips-as.c?rev=256468=256467=256468=diff
==
--- cfe/trunk/test/Driver/freebsd-mips-as.c (original)
+++ cfe/trunk/test/Driver/freebsd-mips-as.c Sun Dec 27 04:36:44 2015
@@ -89,3 +89,9 @@
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2 %s
 // MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+//
+// RUN: %clang -target mips-unknown-freebsd -### \
+// RUN:   -no-integrated-as -G0 -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS32-EB-AS-G0 %s
+// MIPS32-EB-AS-G0: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-G0"
+// MIPS32-EB-AS-G0-NOT: "-KPIC"


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


Re: r256468 - On {mips, mipsel, mips64, mips64el}-freebsd, we need to pass any -G option to the assembler.

2015-12-27 Thread Joerg Sonnenberger via cfe-commits
On Sun, Dec 27, 2015 at 10:36:44AM -, Dimitry Andric via cfe-commits wrote:
> Author: dim
> Date: Sun Dec 27 04:36:44 2015
> New Revision: 256468
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256468=rev
> Log:
> On {mips,mipsel,mips64,mips64el}-freebsd, we need to pass any -G option to 
> the assembler.

Why is this reinventing the wheel and not using AddMIPSTargetArgs?

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


Re: [PATCH] D10137: On {mips, mipsel, mips64, mips64el}-freebsd, we need to pass any -G option to the assembler.

2015-12-27 Thread Dimitry Andric via cfe-commits
dim commandeered this revision.
dim added a reviewer: brooks.
dim added a comment.

Picking this up, since it needs a minor change to apply.


http://reviews.llvm.org/D10137



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


Re: [PATCH] D15166: Fix C++ support on recent DragonFly BSD releases

2015-12-27 Thread Dimitry Andric via cfe-commits
dim added a comment.

Tried this with trunk r256465, but I get the following test failure:

  FAIL: Clang :: Driver/dragonfly.c (3997 of 30174)
   TEST 'Clang :: Driver/dragonfly.c' FAILED 

  Script:
  --
  /home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/./bin/clang  
-no-canonical-prefixes -target x86_64-pc-dragonfly 
/share/dim/src/llvm/trunk/tools/clang/test/Driver/dragonfly.c -### 2> 
/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/tools/clang/test/Driver/Output/dragonfly.c.tmp.log
  
/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/./bin/FileCheck 
-input-file 
/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/tools/clang/test/Driver/Output/dragonfly.c.tmp.log
 /share/dim/src/llvm/trunk/tools/clang/test/Driver/dragonfly.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  /share/dim/src/llvm/trunk/tools/clang/test/Driver/dragonfly.c:5:11: 
error: expected string not found in input
  // CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" 
"/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=gnu" "-o" "a.out" "{{.*}}crt1.o" 
"{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}gcc{{.*}}" "-rpath" 
"{{.*}}gcc{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
  ^
  
/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/tools/clang/test/Driver/Output/dragonfly.c.tmp.log:5:115:
 note: scanning from here
   
"/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/./bin/clang" 
"-cc1" "-triple" "x86_64-pc-dragonfly" "-emit-obj" "-mrelax-all" 
"-disable-free" "-main-file-name" "dragonfly.c" "-mrelocation-model" "static" 
"-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose" 
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" 
"-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" 
"/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/./bin/../lib/clang/3.8.0"
 "-fdebug-compilation-dir" 
"/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/tools/clang/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" 
"-fdiagnostics-show-option" "-o" "/tmp/dragonfly-a045e8.o" "-x" "c" 
"/share/dim/src/llvm/trunk/tools/clang/test/Driver/dragonfly.c"

  ^

@jrmarino, any idea?  The actual output of the script was:

  clang version 3.8.0 (trunk 256465)
  Target: x86_64-pc-dragonfly
  Thread model: posix
  InstalledDir: 
/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/./bin
   "/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/./bin/clang" 
"-cc1" "-triple" "x86_64-pc-dragonfly" "-emit-obj" "-mrelax-all" 
"-disable-free" "-main-file-name" "dragonfly.c" "-mrelocation-model" "static" 
"-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose" 
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" 
"-dwarf-column-info" "-debugger-tuning=gdb" "-resource-dir" 
"/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/./bin/../lib/clang/3.8.0"
 "-fdebug-compilation-dir" 
"/home/dim/obj/llvm-256465M-trunk-freebsd11-i386-ninja-rel-1/tools/clang/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" 
"-fdiagnostics-show-option" "-o" "/tmp/dragonfly-a045e8.o" "-x" "c" 
"/share/dim/src/llvm/trunk/tools/clang/test/Driver/dragonfly.c"
   "/usr/local/bin/ld" "--eh-frame-hdr" "-dynamic-linker" 
"/usr/libexec/ld-elf.so.2" "--hash-style=gnu" "--enable-new-dtags" "-o" "a.out" 
"/usr/lib/crt1.o" "/usr/lib/crti.o" "/usr/lib/crtbegin.o" 
"/tmp/dragonfly-a045e8.o" "-L/usr/lib/gcc50" "-rpath" "/usr/lib/gcc50" "-lc" 
"-lgcc" "--as-needed" "-lgcc_pic" "--no-as-needed" "/usr/lib/crtend.o" 
"/usr/lib/crtn.o"


http://reviews.llvm.org/D15166



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


r256467 - Fix C++ support on recent DragonFly BSD releases

2015-12-27 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Sun Dec 27 04:01:44 2015
New Revision: 256467

URL: http://llvm.org/viewvc/llvm-project?rev=256467=rev
Log:
Fix C++ support on recent DragonFly BSD releases

Summary:
[ Copied from https://llvm.org/bugs/show_bug.cgi?id=25597 ]

Clang support for DragonFly BSD is lagging a bit, resulting in poor
support for c++.

DragonFlyBSD is unique in that it has two base compilers.  At the time
of the last Clang update for DragonFly, these compilers were GCC 4.4 and
GCC 4.7 (default).

With DragonFly Release 4.2, GCC 4.4 was replaced with GCC 5.0, partially
because the C++11 support of GCC 4.7 was incomplete.  The DragonFly
project will Release version 4.4 soon.

This patch updates the Clang driver to use libstdc++ from GCC 5.2 The
support for falling back to the alternate compiler was removed for two
reasons:

1) The last release to use GCC 4.7 is DF 4.0 which has already reached EOL
2) GCC 4.7 libstdc++ is insufficient for many "ports"

Therefore, I think it is reasonable that the development version of
clang expects GCC 5.2 to be in place and not try to fall back to another
compiler.

The attached patch will do this.  The Tools.cpp file was signficantly
modified to fix the linking which had been changed somewhere along the
line.  The rest of the changes should be self-explanatory.

Reviewers: joerg, rsmith, davide

Subscribers: jrmarino, davide, cfe-commits

Differential Revision: http://reviews.llvm.org/D15166

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/test/Driver/dragonfly.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=256467=256466=256467=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sun Dec 27 04:01:44 2015
@@ -4175,10 +4175,7 @@ DragonFly::DragonFly(const Driver , co
 
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
-  if (D.getVFS().exists("/usr/lib/gcc47"))
-getFilePaths().push_back("/usr/lib/gcc47");
-  else
-getFilePaths().push_back("/usr/lib/gcc44");
+  getFilePaths().push_back("/usr/lib/gcc50");
 }
 
 Tool *DragonFly::buildAssembler() const {

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256467=256466=256467=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Dec 27 04:01:44 2015
@@ -9192,7 +9192,6 @@ void dragonfly::Linker::ConstructJob(Com
  const char *LinkingOutput) const {
   const Driver  = getToolChain().getDriver();
   ArgStringList CmdArgs;
-  bool UseGCC47 = llvm::sys::fs::exists("/usr/lib/gcc47");
 
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
@@ -9209,7 +9208,8 @@ void dragonfly::Linker::ConstructJob(Com
   CmdArgs.push_back("-dynamic-linker");
   CmdArgs.push_back("/usr/libexec/ld-elf.so.2");
 }
-CmdArgs.push_back("--hash-style=both");
+CmdArgs.push_back("--hash-style=gnu");
+CmdArgs.push_back("--enable-new-dtags");
   }
 
   // When building 32-bit code on DragonFly/pc64, we have to explicitly
@@ -9255,21 +9255,11 @@ void dragonfly::Linker::ConstructJob(Com
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-// FIXME: GCC passes on -lgcc, -lgcc_pic and a whole lot of
-// rpaths
-if (UseGCC47)
-  CmdArgs.push_back("-L/usr/lib/gcc47");
-else
-  CmdArgs.push_back("-L/usr/lib/gcc44");
+CmdArgs.push_back("-L/usr/lib/gcc50");
 
 if (!Args.hasArg(options::OPT_static)) {
-  if (UseGCC47) {
-CmdArgs.push_back("-rpath");
-CmdArgs.push_back("/usr/lib/gcc47");
-  } else {
-CmdArgs.push_back("-rpath");
-CmdArgs.push_back("/usr/lib/gcc44");
-  }
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back("/usr/lib/gcc50");
 }
 
 if (D.CCCIsCXX()) {
@@ -9284,28 +9274,20 @@ void dragonfly::Linker::ConstructJob(Com
   CmdArgs.push_back("-lc");
 }
 
-if (UseGCC47) {
-  if (Args.hasArg(options::OPT_static) ||
-  Args.hasArg(options::OPT_static_libgcc)) {
+if (Args.hasArg(options::OPT_static) ||
+Args.hasArg(options::OPT_static_libgcc)) {
 CmdArgs.push_back("-lgcc");
 CmdArgs.push_back("-lgcc_eh");
-  } else {
-if (Args.hasArg(options::OPT_shared_libgcc)) {
+} else {
+  if (Args.hasArg(options::OPT_shared_libgcc)) {
   CmdArgs.push_back("-lgcc_pic");
   if (!Args.hasArg(options::OPT_shared))
 CmdArgs.push_back("-lgcc");
-} else {
+  } else {
  

Re: [PATCH] D15166: Fix C++ support on recent DragonFly BSD releases

2015-12-27 Thread Dimitry Andric via cfe-commits
dim updated this revision to Diff 43654.
dim added a comment.

Fix the test to check for --enable-new-dtags.


http://reviews.llvm.org/D15166

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/dragonfly.c

Index: test/Driver/dragonfly.c
===
--- test/Driver/dragonfly.c
+++ test/Driver/dragonfly.c
@@ -2,6 +2,6 @@
 // RUN: FileCheck -input-file %t.log %s
 
 // CHECK: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-dragonfly"
-// CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=both" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}gcc4{{.*}}" "-rpath" "{{.*}}gcc4{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
+// CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=gnu" "--enable-new-dtags" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}gcc{{.*}}" "-rpath" "{{.*}}gcc{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
 
 
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -410,10 +410,7 @@
 }
 break;
   case llvm::Triple::DragonFly:
-if (llvm::sys::fs::exists("/usr/lib/gcc47"))
-  AddPath("/usr/include/c++/4.7", CXXSystem, false);
-else
-  AddPath("/usr/include/c++/4.4", CXXSystem, false);
+AddPath("/usr/include/c++/5.0", CXXSystem, false);
 break;
   case llvm::Triple::OpenBSD: {
 std::string t = triple.getTriple();
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9192,7 +9192,6 @@
  const char *LinkingOutput) const {
   const Driver  = getToolChain().getDriver();
   ArgStringList CmdArgs;
-  bool UseGCC47 = llvm::sys::fs::exists("/usr/lib/gcc47");
 
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
@@ -9209,7 +9208,8 @@
   CmdArgs.push_back("-dynamic-linker");
   CmdArgs.push_back("/usr/libexec/ld-elf.so.2");
 }
-CmdArgs.push_back("--hash-style=both");
+CmdArgs.push_back("--hash-style=gnu");
+CmdArgs.push_back("--enable-new-dtags");
   }
 
   // When building 32-bit code on DragonFly/pc64, we have to explicitly
@@ -9255,21 +9255,11 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-// FIXME: GCC passes on -lgcc, -lgcc_pic and a whole lot of
-// rpaths
-if (UseGCC47)
-  CmdArgs.push_back("-L/usr/lib/gcc47");
-else
-  CmdArgs.push_back("-L/usr/lib/gcc44");
+CmdArgs.push_back("-L/usr/lib/gcc50");
 
 if (!Args.hasArg(options::OPT_static)) {
-  if (UseGCC47) {
-CmdArgs.push_back("-rpath");
-CmdArgs.push_back("/usr/lib/gcc47");
-  } else {
-CmdArgs.push_back("-rpath");
-CmdArgs.push_back("/usr/lib/gcc44");
-  }
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back("/usr/lib/gcc50");
 }
 
 if (D.CCCIsCXX()) {
@@ -9284,28 +9274,20 @@
   CmdArgs.push_back("-lc");
 }
 
-if (UseGCC47) {
-  if (Args.hasArg(options::OPT_static) ||
-  Args.hasArg(options::OPT_static_libgcc)) {
+if (Args.hasArg(options::OPT_static) ||
+Args.hasArg(options::OPT_static_libgcc)) {
 CmdArgs.push_back("-lgcc");
 CmdArgs.push_back("-lgcc_eh");
-  } else {
-if (Args.hasArg(options::OPT_shared_libgcc)) {
+} else {
+  if (Args.hasArg(options::OPT_shared_libgcc)) {
   CmdArgs.push_back("-lgcc_pic");
   if (!Args.hasArg(options::OPT_shared))
 CmdArgs.push_back("-lgcc");
-} else {
+  } else {
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("--as-needed");
   CmdArgs.push_back("-lgcc_pic");
   CmdArgs.push_back("--no-as-needed");
-}
-  }
-} else {
-  if (Args.hasArg(options::OPT_shared)) {
-CmdArgs.push_back("-lgcc_pic");
-  } else {
-CmdArgs.push_back("-lgcc");
   }
 }
   }
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4175,10 +4175,7 @@
 
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
-  if (D.getVFS().exists("/usr/lib/gcc47"))
-getFilePaths().push_back("/usr/lib/gcc47");
-  else
-getFilePaths().push_back("/usr/lib/gcc44");
+  getFilePaths().push_back("/usr/lib/gcc50");
 }
 
 Tool *DragonFly::buildAssembler() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r256472 - Constify NestedNameSpecifier::dump and add a no-argument dump function suitable for calling from a debugger.

2015-12-27 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Sun Dec 27 08:34:22 2015
New Revision: 256472

URL: http://llvm.org/viewvc/llvm-project?rev=256472=rev
Log:
Constify NestedNameSpecifier::dump and add a no-argument dump function suitable 
for calling from a debugger.


Modified:
cfe/trunk/include/clang/AST/NestedNameSpecifier.h
cfe/trunk/lib/AST/NestedNameSpecifier.cpp

Modified: cfe/trunk/include/clang/AST/NestedNameSpecifier.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/NestedNameSpecifier.h?rev=256472=256471=256472=diff
==
--- cfe/trunk/include/clang/AST/NestedNameSpecifier.h (original)
+++ cfe/trunk/include/clang/AST/NestedNameSpecifier.h Sun Dec 27 08:34:22 2015
@@ -217,7 +217,8 @@ public:
 
   /// \brief Dump the nested name specifier to standard output to aid
   /// in debugging.
-  void dump(const LangOptions );
+  void dump(const LangOptions ) const;
+  void dump() const;
 };
 
 /// \brief A C++ nested-name-specifier augmented with source location

Modified: cfe/trunk/lib/AST/NestedNameSpecifier.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/NestedNameSpecifier.cpp?rev=256472=256471=256472=diff
==
--- cfe/trunk/lib/AST/NestedNameSpecifier.cpp (original)
+++ cfe/trunk/lib/AST/NestedNameSpecifier.cpp Sun Dec 27 08:34:22 2015
@@ -318,7 +318,12 @@ NestedNameSpecifier::print(raw_ostream &
   OS << "::";
 }
 
-void NestedNameSpecifier::dump(const LangOptions ) {
+void NestedNameSpecifier::dump(const LangOptions ) const {
+  print(llvm::errs(), PrintingPolicy(LO));
+}
+
+void NestedNameSpecifier::dump() const {
+  LangOptions LO;
   print(llvm::errs(), PrintingPolicy(LO));
 }
 


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


Re: [PATCH] D15704: Add some overlooked optnone tests, and tighten up an existing test

2015-12-27 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for these; I think the optnon-class-members.cpp and 
optnon-templates.cpp have value, so I would say to keep them.


http://reviews.llvm.org/D15704



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2015-12-27 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:22
@@ +21,3 @@
+
+bool inHeaderFile(const SourceManager* SM, SourceLocation Location) {
+  StringRef Filename = SM->getFilename(SM->getExpansionLoc(Location));

This should use isInMainFile() instead of checking the file extension.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:30
@@ +29,3 @@
+void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  decl(anyOf(functionDecl(isDefinition()),

I wonder if you could use an AST matcher to weed out definitions that are in 
the main file to make the matcher a bit more narrow.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:36
@@ +35,3 @@
+void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult ) {
+  // C++ [basic.def.odr]:
+  // There can be more than one definition of a class type, enumeration type,

Please quote the paragraph as well (p6, in this case).


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:44
@@ +43,3 @@
+  // satisfy the following requirements.
+  const auto* ND = Result.Nodes.getNodeAs("decl");
+  if (!ND)

Should be declared: `const auto *ND` (note the position of the *). May want to 
run clang-format over your patch, as this applies elsewhere as well.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:49
@@ +48,3 @@
+return;
+  // Internal linkage variable and function definitions are allowed:
+  //   const int a = 1;

Why are these allowed? They can result in ODR violations if they are in a 
header file.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:69
@@ +68,3 @@
+  return;
+// Member function of a class template and member function of a nest class
+// in a class template are allowed.

nest -> nested


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:77
@@ +76,3 @@
+return;
+DC = DC->getLookupParent();
+  }

Why the lookup parent instead of getParent()? Also, can this ever return a 
nullptr?


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:85
@@ +84,3 @@
+  } else if (const auto* VD = dyn_cast(ND)) {
+// static data member of a class template is allowed.
+if (VD->getDeclContext()->isDependentContext() &&

static -> Static


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.h:19
@@ +18,3 @@
+
+// Finds non-extern non-inline function dand variable definitions in header
+// files, which can lead to potential ODR violations.

dand -> and


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:17
@@ +16,3 @@
+   namespace {
+ int c  = 2; // ok
+   }

I don't think that this should be okay (same with static/const int examples 
above). See 
https://www.securecoding.cert.org/confluence/display/cplusplus/DCL59-CPP.+Do+not+define+an+unnamed+namespace+in+a+header+file
 for more details.


Comment at: unittests/clang-tidy/MiscModuleTest.cpp:38
@@ -36,1 +37,3 @@
 
+class DefinitionsInHeadersCheckTest : public ::testing::Test {
+protected:

Is there a reason this is under unittests instead of as actual clang-tidy test 
files? I would prefer to see this run through clang-tidy on the shell instead 
of in the unit tests, unless there's something we cannot otherwise test.


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15791: Disable generating movt on FreeBSD

2015-12-27 Thread Ed Maste via cfe-commits
emaste added a comment.

> @davide, any idea whether lld will be able to handle movt correctly? If so, 
> we might want to make this dependent on -fuse-ld=bfd or -fuse-ld=lld ?


I'm sure lld will handle everything we need eventually (if it does not 
already), but I'm not sure it's reasonable to have different behaviour based on 
`-fuse-ld` here anyhow -- ld.bfd may well be a recent one from ports.


Repository:
  rL LLVM

http://reviews.llvm.org/D15791



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


Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86

2015-12-27 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:1867
@@ +1866,3 @@
+Clang supports the GNU style ``__attribute__((interrupt))`` attribute on
+x86 targets. This attribute may be attached to a function definition and
+instructs the backend to generate appropriate function entry/exit code so that

Should we also explicitly list x86-64 as well?


Comment at: include/clang/Basic/AttrDocs.td:1889
@@ +1888,3 @@
+
+  and user must properly define the structure the pointer pointing to.
+

"the pointer pointing to"

What do you mean by "properly define"? Do you mean it cannot be an opaque 
pointer, or that there is a particular structure that must be used?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2494
@@ +2493,3 @@
+def err_interrupt_function_wrong_return_type : Error<
+  "interrupt service routine must have void return value">;
+def err_interrupt_function_wrong_args : Error<

It would be good to model these new diagnostics after the MIPS interrupt 
diagnostics.
```
def warn_mips_interrupt_attribute : Warning<
   "MIPS 'interrupt' attribute only applies to functions that have "
   "%select{no parameters|a 'void' return type}0">,
   InGroup;
```



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2501
@@ +2500,3 @@
+  "interrupt service routine should have one of unsigned integer types as the 
second argument">;
+def err_interrupt_function_called : Error<
+  "interrupt service routine can't be used directly">;

"can't be used directly": what does it mean to "use"? Take the address of? 
Call? Pass as an argument to another function call?


Comment at: lib/CodeGen/TargetInfo.cpp:2013
@@ -1998,1 +2012,3 @@
 
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if (FD->hasAttr()) {

Is there a way to prevent this code duplication?


Comment at: lib/Sema/SemaDeclAttr.cpp:4555
@@ +4554,3 @@
+  // e) The 2nd argument (if any) must be an unsigned integer.
+  if (!isFunctionOrMethod(D) || !hasFunctionProto(D) ||
+  !D->getDeclContext()->isFileContext()) {

Based on this, the Subject line in Attr.td should be HasFunctionProto.


Comment at: lib/Sema/SemaDeclAttr.cpp:4556
@@ +4555,3 @@
+  if (!isFunctionOrMethod(D) || !hasFunctionProto(D) ||
+  !D->getDeclContext()->isFileContext()) {
+S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)

This means it is acceptable to have:
```
namespace Foo {
struct interrupt_frame;

__attribute__ ((interrupt))
void f (struct interrupt_frame *frame) {
}
}
```
But not okay to have:
```
struct interrupt_frame;
class Foo {
  __attribute__ ((interrupt))
  static void f (struct interrupt_frame *frame) {
  }
}
```
Is that expected? If you want to disallow namespaces, I think you want 
isTranslationUnit() instead of isFileContext().


Comment at: lib/Sema/SemaDeclAttr.cpp:4558
@@ +4557,3 @@
+S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
+<< Attr.getName() << ExpectedFunction;
+return;

This should be using ExpectedFunctionWithProtoType instead.


Comment at: lib/Sema/SemaDeclAttr.cpp:4568
@@ +4567,3 @@
+  // Interrupt handler must have 1 or 2 parameters.
+  auto NumParams = getFunctionOrMethodNumParams(D);
+  if (NumParams < 1 || NumParams > 2) {

Please do not use auto here.


Comment at: lib/Sema/SemaDeclAttr.cpp:4579
@@ +4578,3 @@
+  }
+  // The second argument must be an unsigned integer.
+  if (NumParams == 2 &&

second argument, if present, must be an unsigned integer.


Comment at: lib/Sema/SemaDeclAttr.cpp:4581
@@ +4580,3 @@
+  if (NumParams == 2 &&
+  !getFunctionOrMethodParamType(D, 1)->isUnsignedIntegerType()) {
+S.Diag(getFunctionOrMethodParamRange(D, 1).getBegin(),

This allows types like bool or __uint128_t; is that permissible?


http://reviews.llvm.org/D15709



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


[clang-tools-extra] r256474 - Renaming CERT documentation files to use the CERT rule identifiers. This is for consistency with other checkers, where the documentation file name matches the checker nam

2015-12-27 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Sun Dec 27 13:14:55 2015
New Revision: 256474

URL: http://llvm.org/viewvc/llvm-project?rev=256474=rev
Log:
Renaming CERT documentation files to use the CERT rule identifiers. This is for 
consistency with other checkers, where the documentation file name matches the 
checker name. NFC of the checkers.

Added:
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl50-cpp.rst
  - copied unchanged from r256473, 
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-variadic-function-def.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err52-cpp.rst
  - copied unchanged from r256473, 
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-setlongjmp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err58-cpp.rst
  - copied unchanged from r256473, 
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-static-object-exception.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err60-cpp.rst
  - copied unchanged from r256473, 
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-thrown-exception-type.rst
Removed:
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-setlongjmp.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/cert-static-object-exception.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/cert-thrown-exception-type.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/cert-variadic-function-def.rst
Modified:
clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.h
clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.h
clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.h
clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.h?rev=256474=256473=256474=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.h Sun Dec 27 
13:14:55 2015
@@ -18,7 +18,7 @@ namespace tidy {
 /// Guards against use of setjmp/longjmp in C++ code
 ///
 /// For the user-facing documentation see:
-/// http://clang.llvm.org/extra/clang-tidy/checks/cert-setlongjmp.html
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-err52-cpp.html
 class SetLongJmpCheck : public ClangTidyCheck {
 public:
   SetLongJmpCheck(StringRef Name, ClangTidyContext *Context)

Modified: clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.h?rev=256474=256473=256474=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.h Sun 
Dec 27 13:14:55 2015
@@ -19,7 +19,7 @@ namespace tidy {
 /// throw.
 ///
 /// For the user-facing documentation see:
-/// 
http://clang.llvm.org/extra/clang-tidy/checks/cert-static-object-exception.html
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-err58-cpp.html
 class StaticObjectExceptionCheck : public ClangTidyCheck {
 public:
   StaticObjectExceptionCheck(StringRef Name, ClangTidyContext *Context)

Modified: clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.h?rev=256474=256473=256474=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.h Sun Dec 
27 13:14:55 2015
@@ -18,7 +18,7 @@ namespace tidy {
 /// Checks whether a thrown object is nothrow copy constructible.
 ///
 /// For the user-facing documentation see:
-/// 
http://clang.llvm.org/extra/clang-tidy/checks/cert-thrown-exception-type.html
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-err60-cpp.html
 class ThrownExceptionTypeCheck : public ClangTidyCheck {
 public:
   ThrownExceptionTypeCheck(StringRef Name, ClangTidyContext *Context)

Modified: clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h?rev=256474=256473=256474=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h Sun Dec 
27 13:14:55 2015
@@ -18,7 +18,7 @@ namespace tidy {
 /// Guards against any C-style variadic function definitions (not 
declarations).
 ///
 

Re: [PATCH] D15791: Disable generating movt on FreeBSD

2015-12-27 Thread Dimitry Andric via cfe-commits
dim added a comment.

In http://reviews.llvm.org/D15791#317175, @emaste wrote:

> > @davide, any idea whether lld will be able to handle movt correctly? If so, 
> > we might want to make this dependent on -fuse-ld=bfd or -fuse-ld=lld ?
>
>
> I'm sure lld will handle everything we need eventually (if it does not 
> already), but I'm not sure it's reasonable to have different behaviour based 
> on `-fuse-ld` here anyhow -- ld.bfd may well be a recent one from ports.


Right, so this really only applies for binutils ld below a certain version, 
then?  IIRC the linker version on the system is detected at configuration time; 
maybe it can be used instead.  Ideally there would be some sort of runtime 
detection, but it does not sound feasible with ld.


Repository:
  rL LLVM

http://reviews.llvm.org/D15791



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


r256478 - [Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC

2015-12-27 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sun Dec 27 15:55:19 2015
New Revision: 256478

URL: http://llvm.org/viewvc/llvm-project?rev=256478=rev
Log:
[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256478=256477=256478=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun Dec 27 15:55:19 2015
@@ -5365,10 +5365,10 @@ public:
 SourceLocation BaseLoc,
 SourceLocation EllipsisLoc);
 
-  bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
-unsigned NumBases);
-  void ActOnBaseSpecifiers(Decl *ClassDecl, CXXBaseSpecifier **Bases,
-   unsigned NumBases);
+  bool AttachBaseSpecifiers(CXXRecordDecl *Class,
+MutableArrayRef Bases);
+  void ActOnBaseSpecifiers(Decl *ClassDecl,
+   MutableArrayRef Bases);
 
   bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base);
   bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base,

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=256478=256477=256478=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sun Dec 27 15:55:19 2015
@@ -1844,7 +1844,7 @@ void Parser::ParseBaseClause(Decl *Class
   }
 
   // Attach the base specifiers
-  Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo.data(), BaseInfo.size());
+  Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
 }
 
 /// ParseBaseSpecifier - Parse a C++ base-specifier. A base-specifier is

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=256478=256477=256478=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Dec 27 15:55:19 2015
@@ -1553,9 +1553,9 @@ NoteIndirectBases(ASTContext , I
 
 /// \brief Performs the actual work of attaching the given base class
 /// specifiers to a C++ class.
-bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
-unsigned NumBases) {
- if (NumBases == 0)
+bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class,
+MutableArrayRef Bases) {
+ if (Bases.empty())
 return false;
 
   // Used to keep track of which base types we have already seen, so
@@ -1571,7 +1571,7 @@ bool Sema::AttachBaseSpecifiers(CXXRecor
   // Copy non-redundant base specifiers into permanent storage.
   unsigned NumGoodBases = 0;
   bool Invalid = false;
-  for (unsigned idx = 0; idx < NumBases; ++idx) {
+  for (unsigned idx = 0; idx < Bases.size(); ++idx) {
 QualType NewBaseType
   = Context.getCanonicalType(Bases[idx]->getType());
 NewBaseType = NewBaseType.getLocalUnqualifiedType();
@@ -1597,7 +1597,7 @@ bool Sema::AttachBaseSpecifiers(CXXRecor
   Bases[NumGoodBases++] = Bases[idx];
 
   // Note this base's direct & indirect bases, if there could be ambiguity.
-  if (NumBases > 1)
+  if (Bases.size() > 1)
 NoteIndirectBases(Context, IndirectBaseTypes, NewBaseType);
   
   if (const RecordType *Record = NewBaseType->getAs()) {
@@ -1619,7 +1619,7 @@ bool Sema::AttachBaseSpecifiers(CXXRecor
   }
 
   // Attach the remaining base class specifiers to the derived class.
-  Class->setBases(Bases, NumGoodBases);
+  Class->setBases(Bases.data(), NumGoodBases);
   
   for (unsigned idx = 0; idx < NumGoodBases; ++idx) {
 // Check whether this direct base is inaccessible due to ambiguity.
@@ -1654,13 +1654,13 @@ bool Sema::AttachBaseSpecifiers(CXXRecor
 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
 /// class, after checking whether there are any duplicate base
 /// classes.
-void Sema::ActOnBaseSpecifiers(Decl *ClassDecl, CXXBaseSpecifier **Bases,
-   unsigned NumBases) {
-  if (!ClassDecl || !Bases || !NumBases)
+void Sema::ActOnBaseSpecifiers(Decl *ClassDecl,
+   MutableArrayRef Bases) {
+  if (!ClassDecl || Bases.empty())
 return;
 
   AdjustDeclIfTemplate(ClassDecl);
-  AttachBaseSpecifiers(cast(ClassDecl), Bases, NumBases);
+  AttachBaseSpecifiers(cast(ClassDecl), Bases);
 }
 
 /// \brief Determine whether the type \p Derived is a C++ class that is

Modified: 

Re: [PATCH] D15055: [X86] Better support for the MCU psABI

2015-12-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



Comment at: lib/CodeGen/TargetInfo.cpp:838
@@ +837,3 @@
+  bool shouldAggregateUseDirect(QualType Ty, CCState , bool ,
+bool ) const;
+  bool shouldPrimitiveUseInReg(QualType Ty, CCState ) const;

formatting seems off


Comment at: lib/CodeGen/TargetInfo.cpp:1256-1257
@@ +1255,4 @@
+bool X86_32ABIInfo::shouldAggregateUseDirect(QualType Ty, CCState , 
+  bool , bool ) const {
+  NeedsPadding = false;
+  InReg = !IsMCUABI;

formatting


http://reviews.llvm.org/D15055



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


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-12-27 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:836
@@ -835,2 +835,3 @@
 
+  bool IsConcept : 1;
 protected:

rsmith wrote:
> This might make more sense on `TemplateDecl`, since we also want this flag 
> for `VarTemplateDecl`s. In any case, please use some existing spare bit for 
> this rather than making all `FunctionTemplateDecl`s 8 bytes larger by putting 
> it here.
@rsmith - Yeah, I originally thought to put it in TemplateDecl but reconsidered 
since ClassTemplateDecls would get it as well . However, I guess by making 
TemplateDecl::TemplatedDecl an IntPointerPair that concern is irrelevant.

@faisalv - Thanks for the info and suggestion! This helped with Richard's 
suggestion (below). FYI - It looks like that IntPointerPair, 
InstantiatedFromMember, is for explicit specializations, and the pointer to 
CommonBase (Common) is null for a function concept's primary template 
declaration. 



Comment at: include/clang/AST/DeclTemplate.h:986
@@ +985,3 @@
+  bool isConcept() const { return IsConcept; }
+  void setConcept(bool IC) { IsConcept = IC; }
+

rsmith wrote:
> Do we need a setter for this? (Can it change after the decl is constructed?)
The setter is used below when we see that `concept` is specified on the 
declaration. So, it wouldn't be initialized (or set)  to true when the decl is 
constructed.  Or, do you have a different opinion on where to set `IsConcept` 
to true such as how `IsConstExpr` is initialized in FunctionDecls being passed 
as a param in the constructor? 


Comment at: lib/Sema/SemaDecl.cpp:7727
@@ +7726,3 @@
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }

Thanks for the suggestion. I'll go with TemplatedDecl and see what you guys 
think.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-12-27 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 43670.
nwilson added a comment.

- Store the IsConcept boolean flag in TemplateDecl by making TemplatedDecl an 
IntPointerPair, and move the associated member functions into TemplateDecl.
- Remove unnecessary quoted comment.
- Remove an extra space where the diagnostic is used.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7668,6 +7668,15 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5988,6 +5988,16 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+  }
 }
   }
 
@@ -7645,6 +7655,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7703,6 +7717,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7964,9 +7987,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   

Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86

2015-12-27 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: include/clang/Basic/Attr.td:255
@@ -254,2 +254,3 @@
 def TargetX86 : TargetArch<["x86"]>;
+def TargetIA : TargetArch<["x86", "x86_64"]>;
 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {

As far as I'm aware, we don't use "IA" as an abbreviation for both x86 targets 
anywhere else, and most people won't recognize it without the -32 or -64 
suffix.  How about "AnyX86"?


Comment at: lib/Sema/SemaDeclAttr.cpp:4593
@@ -4549,3 +4592,3 @@
   // Dispatch the interrupt attribute based on the current target.
   if (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::msp430)
 handleMSP430InterruptAttr(S, D, Attr);

Please go ahead and refactor this into a switch statement.  It's okay to have a 
default case.


Comment at: lib/Sema/SemaExpr.cpp:4972
@@ -4971,1 +4971,3 @@
 }
+if (NDecl && NDecl->hasAttr()) {
+  Diag(Fn->getExprLoc(), diag::err_interrupt_function_called);

I think NDecl has to be non-null here.


http://reviews.llvm.org/D15709



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


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-12-27 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


r256485 - [OPENMP 4.5] Do not allow 'linear' clause along with 'ordered(expr)' clause.

2015-12-27 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Dec 28 00:23:08 2015
New Revision: 256485

URL: http://llvm.org/viewvc/llvm-project?rev=256485=rev
Log:
[OPENMP 4.5] Do not allow 'linear' clause along with 'ordered(expr)' clause.
According to OpenMP 4.5 "A linear clause or an ordered clause with a parameter 
can be specified on a loop directive but not both.""

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_ast_print.cpp
cfe/trunk/test/OpenMP/for_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=256485=256484=256485=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Dec 28 00:23:08 
2015
@@ -7961,6 +7961,8 @@ def err_omp_depend_sink_expected_plus_mi
   "expected '+' or '-' operation">;
 def err_omp_depend_sink_source_not_allowed : Error<
   "'depend(%select{source|sink:vec}0)' clause%select{|s}0 cannot be mixed with 
'depend(%select{sink:vec|source}0)' clause%select{s|}0">;
+def err_omp_linear_ordered : Error<
+  "'linear' clause cannot be specified along with 'ordered' clause with a 
parameter">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=256485=256484=256485=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Dec 28 00:23:08 2015
@@ -1622,6 +1622,9 @@ StmtResult Sema::ActOnOpenMPRegionEnd(St
 ActOnCapturedRegionError();
 return StmtError();
   }
+
+  OMPOrderedClause *OC = nullptr;
+  SmallVector LCs;
   // This is required for proper codegen.
   for (auto *Clause : Clauses) {
 if (isOpenMPPrivate(Clause->getClauseKind()) ||
@@ -1647,6 +1650,18 @@ StmtResult Sema::ActOnOpenMPRegionEnd(St
   MarkDeclarationsReferencedInExpr(E);
 }
 }
+if (Clause->getClauseKind() == OMPC_ordered)
+  OC = cast(Clause);
+else if (Clause->getClauseKind() == OMPC_linear)
+  LCs.push_back(cast(Clause));
+  }
+  if (!LCs.empty() && OC && OC->getNumForLoops()) {
+for (auto *C : LCs) {
+  Diag(C->getLocStart(), diag::err_omp_linear_ordered)
+  << SourceRange(OC->getLocStart(), OC->getLocEnd());
+}
+ActOnCapturedRegionError();
+return StmtError();
   }
   return ActOnCapturedRegionEnd(S.get());
 }

Modified: cfe/trunk/test/OpenMP/for_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_ast_print.cpp?rev=256485=256484=256485=diff
==
--- cfe/trunk/test/OpenMP/for_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/for_ast_print.cpp Mon Dec 28 00:23:08 2015
@@ -20,7 +20,7 @@ T tmain(T argc) {
 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
 // CHECK-NEXT: a = 2;
 #pragma omp parallel
-#pragma omp for private(argc, b), firstprivate(c, d), lastprivate(d, f) 
collapse(N) schedule(static, N) ordered(N) nowait linear(a : N)
+#pragma omp for private(argc, b), firstprivate(c, d), lastprivate(d, f) 
collapse(N) schedule(static, N) ordered(N) nowait
   for (int i = 0; i < 2; ++i)
 for (int j = 0; j < 2; ++j)
   for (int j = 0; j < 2; ++j)
@@ -33,7 +33,7 @@ T tmain(T argc) {
   for (int j = 0; j < 2; ++j)
 foo();
   // CHECK-NEXT: #pragma omp parallel
-  // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(c,d) 
lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) nowait linear(a: N)
+  // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(c,d) 
lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) nowait
   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)

Modified: cfe/trunk/test/OpenMP/for_linear_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_linear_messages.cpp?rev=256485=256484=256485=diff
==
--- cfe/trunk/test/OpenMP/for_linear_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_linear_messages.cpp Mon Dec 28 00:23:08 2015
@@ -145,6 +145,8 @@ template int foomain(I
   for (int k = 0; k < argc; ++k) { ++k; v += j; }
   #pragma omp for linear(i)
   for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause 
cannot be specified along with 'ordered' clause with a parameter}}
+  for (int k = 0; k < argc; ++k) ++k;
   return 0;
 }
 
@@ -207,6 +209,8 @@ int main(int argc, char 

Re: [PATCH] D15647: [X86] Fix stack alignment for MCU target (Clang part)

2015-12-27 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: tools/clang/lib/AST/ASTContext.cpp:1902
@@ +1901,3 @@
+  if (Target->getTriple().getArch() == llvm::Triple::xcore ||
+  Target->getTriple().isOSIAMCU())
+return ABIAlign;  // Never overalign on XCore and IAMCU.

Please turn this into a method or flag on TargetInfo.  I suggest
  bool AllowLargerPreferredTypeAlignment;


http://reviews.llvm.org/D15647



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


r256488 - clang-format: Fix incorrect function type detection.

2015-12-27 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 28 01:44:25 2015
New Revision: 256488

URL: http://llvm.org/viewvc/llvm-project?rev=256488=rev
Log:
clang-format: Fix incorrect function type detection.

Before:
  int x = f ()();

After:
  int x = f()();

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256488=256487=256488=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Dec 28 01:44:25 2015
@@ -148,6 +148,10 @@ private:
 } else if (Left->Previous && Left->Previous->MatchingParen &&
Left->Previous->MatchingParen->is(TT_ObjCBlockLParen)) {
   Contexts.back().IsExpression = false;
+} else if (!Line.MustBeDeclaration && !Line.InPPDirective) {
+  bool IsForOrCatch =
+  Left->Previous && Left->Previous->isOneOf(tok::kw_for, 
tok::kw_catch);
+  Contexts.back().IsExpression = !IsForOrCatch;
 }
 
 if (StartsObjCMethodExpr) {
@@ -155,7 +159,8 @@ private:
   Left->Type = TT_ObjCMethodExpr;
 }
 
-bool MightBeFunctionType = CurrentToken->isOneOf(tok::star, tok::amp);
+bool MightBeFunctionType = CurrentToken->isOneOf(tok::star, tok::amp) &&
+   !Contexts[Contexts.size() - 2].IsExpression;
 bool HasMultipleLines = false;
 bool HasMultipleParametersOnALine = false;
 bool MightBeObjCForRangeLoop =
@@ -189,7 +194,7 @@ private:
 if (MightBeFunctionType && CurrentToken->Next &&
 (CurrentToken->Next->is(tok::l_paren) ||
  (CurrentToken->Next->is(tok::l_square) &&
-  !Contexts.back().IsExpression)))
+  Line.MustBeDeclaration)))
   Left->Type = TT_FunctionTypeLParen;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
@@ -861,17 +866,6 @@ private:
   Contexts.back().IsExpression = false;
 } else if (Current.is(TT_LambdaArrow) || Current.is(Keywords.kw_assert)) {
   Contexts.back().IsExpression = Style.Language == FormatStyle::LK_Java;
-} else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration &&
-   !Line.InPPDirective &&
-   (!Current.Previous ||
-Current.Previous->isNot(tok::kw_decltype))) {
-  bool ParametersOfFunctionType =
-  Current.Previous && Current.Previous->is(tok::r_paren) &&
-  Current.Previous->MatchingParen &&
-  Current.Previous->MatchingParen->is(TT_FunctionTypeLParen);
-  bool IsForOrCatch = Current.Previous &&
-  Current.Previous->isOneOf(tok::kw_for, 
tok::kw_catch);
-  Contexts.back().IsExpression = !ParametersOfFunctionType && 
!IsForOrCatch;
 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
   for (FormatToken *Previous = Current.Previous;
Previous && Previous->isOneOf(tok::star, tok::amp);
@@ -1112,8 +1106,7 @@ private:
 Tok.Previous->isSimpleTypeSpecifier();
 bool ParensCouldEndDecl =
 Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
-if (ParensAreType && !ParensCouldEndDecl &&
-(Contexts.size() > 1 && Contexts[Contexts.size() - 2].IsExpression))
+if (ParensAreType && !ParensCouldEndDecl)
   return true;
 
 // At this point, we heuristically assume that there are no casts at the

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256488=256487=256488=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 28 01:44:25 2015
@@ -5928,6 +5928,7 @@ TEST_F(FormatTest, FormatsFunctionTypes)
   verifyFormat("#define DEREF_AND_CALL_F(x) f(*x)");
   verifyFormat("some_var = function(*some_pointer_var)[0];");
   verifyFormat("void f() { function(*some_pointer_var)[0] = 10; }");
+  verifyFormat("int x = f()();");
 }
 
 TEST_F(FormatTest, FormatsPointersToArrayTypes) {


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


r256487 - [OPENMP 4.5] Sema/parsing support for extended format of 'schedule' clause.

2015-12-27 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Dec 28 01:25:51 2015
New Revision: 256487

URL: http://llvm.org/viewvc/llvm-project?rev=256487=rev
Log:
[OPENMP 4.5] Sema/parsing support for extended format of 'schedule' clause.
OpenMP 4.0-3.1 supports the next format of ‘schedule’ clause: schedule(kind[, 
chunk_size])
Where kind can be one of ‘static’, ‘dynamic’, ‘guided’, ‘auto’ or ‘runtime’.
OpenMP 4.5 defines the format: schedule([modifier [, modifier]:]kind[, 
chunk_size])
Modifier can be one of ‘monotonic’, ‘nonmonotonic’ or ‘simd’.


Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/for_schedule_messages.cpp
cfe/trunk/test/OpenMP/for_simd_schedule_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_schedule_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_schedule_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=256487=256486=256487=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Dec 28 01:25:51 2015
@@ -664,6 +664,11 @@ class OMPScheduleClause : public OMPClau
   SourceLocation LParenLoc;
   /// \brief A kind of the 'schedule' clause.
   OpenMPScheduleClauseKind Kind;
+  /// \brief Modifiers for 'schedule' clause.
+  enum {FIRST, SECOND, NUM_MODIFIERS};
+  OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS];
+  /// \brief Locations of modifiers.
+  SourceLocation ModifiersLoc[NUM_MODIFIERS];
   /// \brief Start location of the schedule ind in source code.
   SourceLocation KindLoc;
   /// \brief Location of ',' (if any).
@@ -678,6 +683,42 @@ class OMPScheduleClause : public OMPClau
   /// \param K Schedule kind.
   ///
   void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; }
+  /// \brief Set the first schedule modifier.
+  ///
+  /// \param M Schedule modifier.
+  ///
+  void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) {
+Modifiers[FIRST] = M;
+  }
+  /// \brief Set the second schedule modifier.
+  ///
+  /// \param M Schedule modifier.
+  ///
+  void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) {
+Modifiers[SECOND] = M;
+  }
+  /// \brief Set location of the first schedule modifier.
+  ///
+  void setFirstScheduleModifierLoc(SourceLocation Loc) {
+ModifiersLoc[FIRST] = Loc;
+  }
+  /// \brief Set location of the second schedule modifier.
+  ///
+  void setSecondScheduleModifierLoc(SourceLocation Loc) {
+ModifiersLoc[SECOND] = Loc;
+  }
+  /// \brief Set schedule modifier location.
+  ///
+  /// \param M Schedule modifier location.
+  ///
+  void setScheduleModifer(OpenMPScheduleClauseModifier M) {
+if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown)
+  Modifiers[FIRST] = M;
+else {
+  assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown);
+  Modifiers[SECOND] = M;
+}
+  }
   /// \brief Sets the location of '('.
   ///
   /// \param Loc Location of '('.
@@ -716,15 +757,25 @@ public:
   /// \param Kind Schedule kind.
   /// \param ChunkSize Chunk size.
   /// \param HelperChunkSize Helper chunk size for combined directives.
+  /// \param M1 The first modifier applied to 'schedule' clause.
+  /// \param M1Loc Location of the first modifier
+  /// \param M2 The second modifier applied to 'schedule' clause.
+  /// \param M2Loc Location of the second modifier
   ///
   OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc,
 SourceLocation KLoc, SourceLocation CommaLoc,
 SourceLocation EndLoc, OpenMPScheduleClauseKind Kind,
-Expr *ChunkSize, Expr *HelperChunkSize)
+Expr *ChunkSize, Expr *HelperChunkSize,
+OpenMPScheduleClauseModifier M1, SourceLocation M1Loc,
+OpenMPScheduleClauseModifier M2, SourceLocation M2Loc)
   : OMPClause(OMPC_schedule, StartLoc, EndLoc), LParenLoc(LParenLoc),
 Kind(Kind), KindLoc(KLoc), CommaLoc(CommaLoc) {
 ChunkSizes[CHUNK_SIZE] = ChunkSize;
 ChunkSizes[HELPER_CHUNK_SIZE] = HelperChunkSize;
+Modifiers[FIRST] = M1;
+Modifiers[SECOND] = M2;
+ModifiersLoc[FIRST] = M1Loc;
+ModifiersLoc[SECOND] = M2Loc;
   }
 
   /// \brief Build an empty clause.
@@ -734,17 +785,39 @@ public:
 Kind(OMPC_SCHEDULE_unknown) {
 ChunkSizes[CHUNK_SIZE] = nullptr;