Re: [PATCH] D15888: [Analyzer] Change the default SA checkers for PS4

2016-01-06 Thread Sean Eveson via cfe-commits
seaneveson updated this revision to Diff 44098.
seaneveson marked an inline comment as done.
seaneveson added a comment.

Removing old "experimental" comment


http://reviews.llvm.org/D15888

Files:
  lib/Driver/Tools.cpp
  test/Driver/ps4-analyzer-defaults.cpp

Index: test/Driver/ps4-analyzer-defaults.cpp
===
--- /dev/null
+++ test/Driver/ps4-analyzer-defaults.cpp
@@ -0,0 +1,33 @@
+// Check that the default analyzer checkers for PS4 are:
+//   core
+//   cplusplus
+//   deadcode
+//   nullability
+//   unix
+// Excluding:
+//   unix.API
+//   unix.Vfork
+
+// Check for expected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-POS-CHECKERS
+//
+// Negative check for unexpected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-NEG-CHECKERS
+//
+// Check for all unix checkers except API and Vfork
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-UNIX-CHECKERS
+
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=core
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=cplusplus
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=deadcode
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=nullability
+//
+// CHECK-PS4-NEG-CHECKERS-NOT: analyzer-checker={{osx|security}}
+//
+// CHECK-PS4-UNIX-CHECKERS: analyzer-checker=unix
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.API
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.Vfork
+// CHECK-PS4-UNIX-CHECKERS-NOT: analyzer-checker=unix.{{API|Vfork}}
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3592,6 +3592,12 @@
   if (!IsWindowsMSVC)
 CmdArgs.push_back("-analyzer-checker=unix");
 
+  // Disable some unix checkers for PS4.
+  if (IsPS4CPU) {
+CmdArgs.push_back("-analyzer-disable-checker=unix.API");
+CmdArgs.push_back("-analyzer-disable-checker=unix.Vfork");
+  }
+
   if (getToolChain().getTriple().getVendor() == llvm::Triple::Apple)
 CmdArgs.push_back("-analyzer-checker=osx");
 
@@ -3600,14 +3606,15 @@
   if (types::isCXX(Input.getType()))
 CmdArgs.push_back("-analyzer-checker=cplusplus");
 
-  // Enable the following experimental checkers for testing.
-  CmdArgs.push_back(
-  "-analyzer-checker=security.insecureAPI.UncheckedReturn");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+  if (!IsPS4CPU) {
+CmdArgs.push_back(
+"-analyzer-checker=security.insecureAPI.UncheckedReturn");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+  }
 
   // Default nullability checks.
   CmdArgs.push_back("-analyzer-checker=nullability.NullPassedToNonnull");


Index: test/Driver/ps4-analyzer-defaults.cpp
===
--- /dev/null
+++ test/Driver/ps4-analyzer-defaults.cpp
@@ -0,0 +1,33 @@
+// Check that the default analyzer checkers for PS4 are:
+//   core
+//   cplusplus
+//   deadcode
+//   nullability
+//   unix
+// Excluding:
+//   unix.API
+//   unix.Vfork
+
+// Check for expected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-POS-CHECKERS
+//
+// Negative check for unexpected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-NEG-CHECKERS
+//
+// Check for all unix checkers except API and Vfork
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-UNIX-CHECKERS
+
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=core
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=cplusplus
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=deadcode
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=nullability
+//
+// CHECK-PS4-NEG-CHECKERS-NOT: analyzer-checker={{osx|security}}
+//
+// CHECK-PS4-UNIX-CHECKERS: analyzer-checker=unix
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.API
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.Vfork
+// CHECK

Re: r256920 - Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-06 Thread Joerg Sonnenberger via cfe-commits
On Wed, Jan 06, 2016 at 07:42:18AM -, Dimitry Andric via cfe-commits wrote:
> Author: dim
> Date: Wed Jan  6 01:42:18 2016
> New Revision: 256920
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256920&view=rev
> Log:
> Add -fno-movt frontend option, to disable movt/movw on ARM

Commit message is wrong of course, it is -mno-movt ;)

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


r256926 - [Analyzer] Change the default SA checkers for PS4

2016-01-06 Thread Sean Eveson via cfe-commits
Author: seaneveson
Date: Wed Jan  6 04:03:58 2016
New Revision: 256926

URL: http://llvm.org/viewvc/llvm-project?rev=256926&view=rev
Log:
[Analyzer] Change the default SA checkers for PS4

Summary: This patch removes security.*, unix.API and unix.Vfork from the 
default checkers for PS4.

Reviewers: dcoughlin, zaks.anna

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Driver/ps4-analyzer-defaults.cpp
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256926&r1=256925&r2=256926&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 04:03:58 2016
@@ -3592,6 +3592,12 @@ void Clang::ConstructJob(Compilation &C,
   if (!IsWindowsMSVC)
 CmdArgs.push_back("-analyzer-checker=unix");
 
+  // Disable some unix checkers for PS4.
+  if (IsPS4CPU) {
+CmdArgs.push_back("-analyzer-disable-checker=unix.API");
+CmdArgs.push_back("-analyzer-disable-checker=unix.Vfork");
+  }
+
   if (getToolChain().getTriple().getVendor() == llvm::Triple::Apple)
 CmdArgs.push_back("-analyzer-checker=osx");
 
@@ -3600,14 +3606,15 @@ void Clang::ConstructJob(Compilation &C,
   if (types::isCXX(Input.getType()))
 CmdArgs.push_back("-analyzer-checker=cplusplus");
 
-  // Enable the following experimental checkers for testing.
-  CmdArgs.push_back(
-  "-analyzer-checker=security.insecureAPI.UncheckedReturn");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+  if (!IsPS4CPU) {
+CmdArgs.push_back(
+"-analyzer-checker=security.insecureAPI.UncheckedReturn");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+  }
 
   // Default nullability checks.
   CmdArgs.push_back("-analyzer-checker=nullability.NullPassedToNonnull");

Added: cfe/trunk/test/Driver/ps4-analyzer-defaults.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-analyzer-defaults.cpp?rev=256926&view=auto
==
--- cfe/trunk/test/Driver/ps4-analyzer-defaults.cpp (added)
+++ cfe/trunk/test/Driver/ps4-analyzer-defaults.cpp Wed Jan  6 04:03:58 2016
@@ -0,0 +1,33 @@
+// Check that the default analyzer checkers for PS4 are:
+//   core
+//   cplusplus
+//   deadcode
+//   nullability
+//   unix
+// Excluding:
+//   unix.API
+//   unix.Vfork
+
+// Check for expected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-POS-CHECKERS
+//
+// Negative check for unexpected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-NEG-CHECKERS
+//
+// Check for all unix checkers except API and Vfork
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-UNIX-CHECKERS
+
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=core
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=cplusplus
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=deadcode
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=nullability
+//
+// CHECK-PS4-NEG-CHECKERS-NOT: analyzer-checker={{osx|security}}
+//
+// CHECK-PS4-UNIX-CHECKERS: analyzer-checker=unix
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.API
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.Vfork
+// CHECK-PS4-UNIX-CHECKERS-NOT: analyzer-checker=unix.{{API|Vfork}}


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


[PATCH] D15920: [CMake] Add option to switch default C++ stdlib

2016-01-06 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: chandlerc, mclow.lists, beanz.
Hahnfeld added a subscriber: cfe-commits.
Herald added subscribers: srhines, danalbert, tberghammer.

With this option one can set the default library to use if no `-stdlib=` is 
provided on compiler invocation (currently hard coded `libstdc++` which remains 
default)
Also add explicit option `-stdlib=libstdc++` to tests that require it and would 
fail when you choose `libc++`.

I haven't touched autotools which should be removed soon anyway. I'm fine if 
either someone else looks into it or if the patch only gets accepted afterwards.

http://reviews.llvm.org/D15920

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  include/clang/Config/config.h.in
  lib/Driver/ToolChain.cpp
  test/Driver/android-standalone.cpp
  test/Driver/darwin-iphone-defaults.m
  test/Driver/darwin-objc-gc.m
  test/Driver/darwin-sanitizer-ld.c
  test/Driver/gcc-toolchain.cpp
  test/Driver/linux-header-search.cpp
  test/Driver/mips-cs.cpp
  test/Driver/mips-fsf.cpp
  test/Driver/mips-img.cpp
  test/Driver/sanitizer-ld.c
  test/Driver/windows-cross.c
  unittests/libclang/LibclangTest.cpp

Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -485,7 +485,7 @@
   WriteFile(Clang, "");
 
   const char *Argv[] = {Clang.c_str(), "-target", "arm-linux-gnueabi",
-"--gcc-toolchain="};
+"-stdlib=libstdc++", "--gcc-toolchain="};
 
   EXPECT_EQ(CXError_Success,
 clang_parseTranslationUnit2FullArgv(Index, Filename.c_str(), Argv,
Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -1,9 +1,9 @@
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -o /dev/null %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -stdlib=libstdc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-BASIC
 
 // CHECK-BASIC: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -o /dev/null %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -stdlib=libstdc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-RTLIB
 
 // CHECK-RTLIB: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}clang_rt.builtins-arm.lib"
@@ -33,7 +33,7 @@
 
 // CHECK-STANDALONE: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-shared" "-Bdynamic" "--enable-auto-image-base" "--entry" "_DllMainCRTStartup" "--allow-multiple-definition" "-o" "shared.dll" "--out-implib" "shared.lib" "{{.*}}.o"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %/Inputs/Windows/ARM/8.1/usr/bin -shared -o shared.dll -x c++ %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %/Inputs/Windows/ARM/8.1/usr/bin -stdlib=libstdc++ -shared -o shared.dll -x c++ %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix CHECK-LIBSTDCXX
 
 // CHECK-LIBSTDCXX:  "-internal-isystem" "{{.*}}/usr/include/c++" "-internal-isystem" "{{.*}}/usr/include/c++/armv7--windows-itanium" "-internal-isystem" "{{.*}}/usr/include/c++/backwards"
Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -76,7 +76,7 @@
 // CHECK-ASAN-FREEBSD-LDL-NOT: "-ldl"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux -fsanitize=address \
+// RUN: -target i386-unknown-linux -stdlib=libstdc++ -fsanitize=address \
 // RUN: -resource-dir=%S/Inputs/empty_resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s
@@ -93,8 +93,8 @@
 // CHECK-ASAN-LINUX-CXX: "-ldl"
 
 /

Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4283
@@ +4282,3 @@
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(notMatchesC("void f();", functionProtoType()));

> I don't understand what would be tested by adding a test for 
> parameterCountIs() on a function that doesn't have a prototype since it is a 
> nested matcher passed to functionProtoType() and since the function doesn't 
> have a prototype, that outer matcher won't match.

Not according to the AST matcher that was implemented -- it supports 
FunctionProtoType and FunctionDecl. I want to make sure that if you get to 
parameterCountIs() through functionDecl() that it doesn't fail.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4992
@@ +4991,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",

> I'm happy to make the improvement, but I don't know how. I simply call the 
> Node.underlyingType(), just like hasType calls Node.getType(). I don't know 
> why they are different.

hasType() and hasUnderlyingType() have different operational semantic 
implications, at least to me. hasType() asks, "ultimately, what is the type of 
this thing?", and Node.underlyingType() answers that. To me, 
hasUnderlyingType() asks, "in the chain of types that this typedef refers to, 
does this thing match any of them?", and Node.underlyingType() does not answer 
that -- it only looks at the final desugared type. The difference we want is 
that hasType() continues to look at the final type, but hasUnderlyingType() 
needs to do more work to look at intermediary types and terminate that loop 
when the answer is "yes, it has this type" or "no, we can't desugar any 
further."

If we don't care about the intermediate types for your needs, then I don't see 
the point to hasUnderlyingType() being an AST matcher at all. hasType() does 
exactly what is needed, and you can instead modify that to accept a TypedefDecl 
in addition to Expr and ValueDecl. However, I still see value in 
hasUnderlyingType() because typedef chains can be long and complex (like in the 
Win32 APIs), and being able to query for intermediary types would be useful. 
e.g., I want to know about all types that have an intermediary type of DWORD 
(which itself is a typedef for an unsigned integer type). hasType() will always 
go to the final type, making such a matcher impossible without something like 
hasUnderlyingType().


http://reviews.llvm.org/D8149



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


[PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-06 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin.
xazax.hun added subscribers: cfe-commits, dkrupp.

This patch adds a small utility to match function calls and Obj-C messages. 
This utility abstracts away the mutable keywords and the lazy initialization 
and caching logic of identifiers from the checkers. The SimpleStreamChecker is 
ported over this utility within this patch to show the reduction of code and to 
test this change.

http://reviews.llvm.org/D15921

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
  lib/StaticAnalyzer/Core/CheckerContext.cpp

Index: lib/StaticAnalyzer/Core/CheckerContext.cpp
===
--- lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Lex/Lexer.h"
 
@@ -35,6 +36,26 @@
   return funI->getName();
 }
 
+bool CheckerContext::isCalled(const CallEvent &Call,
+  const CallDescription &CD) {
+  assert(Call.getKind() != CE_ObjCMessage);
+  if (!CD.II)
+CD.II = &getASTContext().Idents.get(CD.FuncName);
+  if (CD.RequiredArgs != CallDescription::NoArgRequirement &&
+  CD.RequiredArgs != Call.getNumArgs())
+return false;
+  return Call.getCalleeIdentifier() == CD.II;
+}
+
+bool CheckerContext::isCalled(const ObjCMethodCall &Call,
+  const CallDescription &CD) {
+  if (!CD.II)
+CD.II = &getASTContext().Idents.get(CD.FuncName);
+  if (CD.RequiredArgs != CallDescription::NoArgRequirement &&
+  CD.RequiredArgs != Call.getNumArgs())
+return false;
+  return Call.getSelector() == getASTContext().Selectors.getSelector(0, &CD.II);
+}
 
 bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
 StringRef Name) {
@@ -91,4 +112,3 @@
   SmallVector buf;
   return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOpts());
 }
-
Index: lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
@@ -51,14 +51,11 @@
check::PreCall,
check::DeadSymbols,
check::PointerEscape> {
-
-  mutable IdentifierInfo *IIfopen, *IIfclose;
+  CallDescription OpenFn, CloseFn;
 
   std::unique_ptr DoubleCloseBugType;
   std::unique_ptr LeakBugType;
 
-  void initIdentifierInfo(ASTContext &Ctx) const;
-
   void reportDoubleClose(SymbolRef FileDescSym,
  const CallEvent &Call,
  CheckerContext &C) const;
@@ -106,7 +103,7 @@
 } // end anonymous namespace
 
 SimpleStreamChecker::SimpleStreamChecker()
-: IIfopen(nullptr), IIfclose(nullptr) {
+: OpenFn("fopen"), CloseFn("fclose", 1) {
   // Initialize the bug types.
   DoubleCloseBugType.reset(
   new BugType(this, "Double fclose", "Unix Stream API Error"));
@@ -119,12 +116,10 @@
 
 void SimpleStreamChecker::checkPostCall(const CallEvent &Call,
 CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfopen)
+  if (!C.isCalled(Call, OpenFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -140,15 +135,10 @@
 
 void SimpleStreamChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfclose)
-return;
-
-  if (Call.getNumArgs() != 1)
+  if (!C.isCalled(Call, CloseFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -275,13 +265,6 @@
   return State;
 }
 
-void SimpleStreamChecker::initIdentifierInfo(ASTContext &Ctx) const {
-  if (IIfopen)
-return;
-  IIfopen = &Ctx.Idents.get("fopen");
-  IIfclose = &Ctx.Idents.get("fclose");
-}
-
 void ento::registerSimpleStreamChecker(CheckerManager &mgr) {
   mgr.registerChecker();
 }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -66,6 +66,28 @@
   #define REGISTER_LIST_WITH_PROGRAMSTATE(Name, Elem) \
 REGISTER_TRAIT_WITH_PROGRAMSTATE(Na

Re: [PATCH] D14329: Show inclusions from a preamble in clang_getInclusions.

2016-01-06 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the fix!



Comment at: tools/libclang/CIndexInclusionStack.cpp:32
@@ -36,13 +31,3 @@
   SmallVector InclusionStack;
-  unsigned n =  SM.local_sloc_entry_size();
-
-  // In the case where all the SLocEntries are in an external source, traverse
-  // those SLocEntries as well.  This is the case where we are looking
-  // at the inclusion stack of an AST/PCH file.
-  const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const;
-  if (n == 1) {
-Getter = &SourceManager::getLoadedSLocEntry;
-n = SM.loaded_sloc_entry_size();
-  } else
-Getter = &SourceManager::getLocalSLocEntry;
+  const bool hasPreamble = SM.getPreambleFileID().isValid();
 

There's already a wild mix of coding styles in this file, let's not add more of 
them. `bool HasPreamble` is the preferred style.


http://reviews.llvm.org/D14329



___
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.

2016-01-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:26
@@ +25,3 @@
+  StringRef Filename = SM.getFilename(ExpansionLoc);
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||
+ Filename.endswith(".hpp") || Filename.endswith(".hxx");

>Having to configure this in a single place would be convenient. OTOH, I can 
>imagine corner-cases, where a single option would be undesired. One thing we 
>could do is to allow global options that can be overridden for each check. 
>Something along the lines of (modulo tests):

> Alternatively, we could add another method (e.g. getLocalOrGlobal) to make 
> the usage of the global setting explicit.
> 
> What do you think?

I think that's a good idea, and definitely agree it can be done in a follow-up 
patch.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:27
@@ +26,3 @@
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||
+ Filename.endswith(".hpp") || Filename.endswith(".hxx");
+}

I think we should also have a case for an extension-less file here (for people 
who write headers like ).


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:20
@@ +19,3 @@
+   const int c = 1;
+   namespace {
+ int f = 2;

hokein wrote:
> Done. I have also updated my comments here for these cases. Right now it 
> should be ready for review again. Thanks.
> I suggest that we ignore these for now and maybe add an option later.

For the static and const declarations I can see some benefit to ignoring for 
now, but the unnamed namespace in a header file is sufficiently nasty that many 
coding guidelines explicitly forbid it because of ODR violations (it really 
doesn't do what users think it will do). It's especially strange that we will 
warn about using a *named* namespace in a header file, but not an *unnamed* 
namespace, which is decidedly more behaviorally strange. I would prefer to see 
the check catch at least unnamed namespaces, if not static or const variable 
declarations.

Also, I would be interested in hearing what "a lot of such usages in Google" 
means in more concrete terms for static or const definitions in header files, 
if you're able to share those numbers. I don't foresee that changing the 
requirements for this patch, but I'd still be curious to know for when I work 
on CERT's secure coding rules.


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: r256854 - [OpenMP] Allow file ID to be signed in the offloading metadata.

2016-01-06 Thread Samuel F Antao via cfe-commits

The patch was reapplied in r256933 and includes the fixes for the different
regressions that were identified, including the one reported below.

Thanks for your help!
Samuel



From:   "Liao, Michael" 
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits , Artem Belevich

Date:   01/05/2016 07:58 PM
Subject:RE: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.



Hi Samuel

The issue is not related to capture feature but the order of evaluation
which is not specified for arguments in a function call in C/C++. With the
side effect in each argument evaluation, it causes the trouble.

Thanks
- Michael

From: Samuel F Antao [mailto:sfan...@us.ibm.com]
Sent: Tuesday, January 5, 2016 4:25 PM
To: Liao, Michael 
Cc: cfe-commits ; Artem Belevich

Subject: RE: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.



Hi Michael,

Thanks for the patch! I am not sure I understand why the behavior is
unspecified if Idx is captured by reference, but that is good to know that
it fixes the problem. I reverted the patch in the meantime given that I am
still trying to replicate a problem I get from the ARM bots, but I will
incorporate your fix when I am ready to reapply the patch.

Thanks again!
Samuel

Inactive hide details for "Liao, Michael" ---01/05/2016 05:17:13 PM---Hi
Samual The change in CL#256842 has undefined behavior "Liao, Michael"
---01/05/2016 05:17:13 PM---Hi Samual The change in CL#256842 has undefined
behavior according to C++. Attached patch will avoid

From: "Liao, Michael" 
To: Samuel F Antao/Watson/IBM@IBMUS, Artem Belevich 
Cc: cfe-commits 
Date: 01/05/2016 05:17 PM
Subject: RE: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.




Hi Samual

The change in CL#256842 has undefined behavior according to C++. Attached
patch will avoid side-effect code during argument evaluation of a function
call. That solves the problem for me on Linux with GCC 4.9.

Thanks
- Michael

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
Samuel F Antao via cfe-commits
Sent: Tuesday, January 5, 2016 10:57 AM
To: Artem Belevich 
Cc: cfe-commits 
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.


Hi Art,

That only fixed one of the problems. The other one I am having some trouble
to replicate. I am trying a few things and hopefully will get a fix soon.

Sorry for the trouble,
Samuel

Inactive hide details for Artem Belevich ---01/05/2016 01:54:02
PM---Samuel, The tests are still failing:Artem Belevich ---01/05/2016
01:54:02 PM---Samuel, The tests are still failing:

From: Artem Belevich 
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits 
Date: 01/05/2016 01:54 PM
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.





Samuel,

The tests are still failing:
http://lab.llvm.org:8011/builders/clang-bpf-build/builds/5759



On Tue, Jan 5, 2016 at 10:02 AM, Samuel Antao via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
Author: sfantao
Date: Tue Jan 5 12:02:24 2016
New Revision: 256854

URL: http://llvm.org/viewvc/llvm-project?rev=256854&view=rev
Log:
[OpenMP] Allow file ID to be signed in the offloading metadata.

This fixes a regression introduced by rL256842.


Modified:
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=256854&r1=256853&r2=256854&view=diff


==

--- cfe/trunk/test/OpenMP/target_codegen_registration.cpp
(original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Tue
Jan 5 12:02:24 2016
@@ -407,7 +407,7 @@ int bar(int a){

// Check metadata is properly generated:
// CHECK: !omp_offload.info
= !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}}

-// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
[[FILEID:[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32
{{[0-9]}}+}
+// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
[[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32
{{[0-9]}}+}
// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32
[[FILEID]] !"_ZN2SDD2Ev", i32 210, i32 13, i32 {{[0-9]}}+}
// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32
[[FILEID]] !"_ZN2SEC2Ev", i32 226, i32 13, i32 {{[0-9]}}+}
// CHECK-DAG = !{i32 0, i

r256934 - [Hexagon] Use back_inserter as target iterator in std::copy

2016-01-06 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Jan  6 08:13:11 2016
New Revision: 256934

URL: http://llvm.org/viewvc/llvm-project?rev=256934&view=rev
Log:
[Hexagon] Use back_inserter as target iterator in std::copy

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=256934&r1=256933&r2=256934&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Jan  6 08:13:11 2016
@@ -2611,7 +2611,8 @@ void HexagonToolChain::getHexagonLibrary
   // Other standard paths
   
//
   std::vector RootDirs;
-  std::copy(D.PrefixDirs.begin(), D.PrefixDirs.end(), RootDirs.begin());
+  std::copy(D.PrefixDirs.begin(), D.PrefixDirs.end(),
+std::back_inserter(RootDirs));
 
   std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
   D.PrefixDirs);


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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2016-01-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I notice there are a few other comments from reviewers that have not been 
addressed -- is there a newer version of the patch that hasn't been uploaded 
yet, or are you looking for further information on some of the comments?



Comment at: clang-tidy/misc/StdSwapCheck.cpp:26
@@ +25,3 @@
+ASTContext &Ctx,
+bool IsDecl) {
+  SourceManager &SM = Ctx.getSourceManager();

> We should put that somewhere into Tooling/Core. Adding Benjamin who is our 
> master of Yaks :D

At the very least, this could live in clangTidyUtils, possibly in LexerUtils.h.


Comment at: clang-tidy/misc/StdSwapCheck.cpp:65
@@ +64,3 @@
+  Finder->addMatcher(
+//callExpr(callee(functionDecl(hasName("swap"))),
+callExpr(callee(namedDecl(hasName("swap"))),

Please remove commented out code.


Comment at: clang-tidy/misc/StdSwapCheck.cpp:77
@@ +76,3 @@
+
+//   bool isGlobalNS = 
NamespaceDecl::castToDeclContext(nsNode->getNestedNameSpecifier()->getAsNamespace())->getParent()->isTranslationUnit();
+//   if (isGlobalNS && (nsStr == "std" || nsStr == "::std")) {

Please remove commented-out code (here and elsewhere).


Comment at: clang-tidy/misc/StdSwapCheck.h:20
@@ +19,3 @@
+///with calls that use ADL instead.
+///
+/// For the user-facing documentation see:

> I like that indentation :-) 
> It indicates that this is a continuation of the previous line.

It's not the style of commenting that we use in the rest of the project, 
however.


http://reviews.llvm.org/D15121



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


[PATCH] D15924: [analyzer] Utility to extract the variable name from a memory region.

2016-01-06 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, Alexander_Droste.
xazax.hun added subscribers: cfe-commits, dkrupp.

This patch adds a small utility to extract variable name from a memory region.
This patch does not contain any test or user yet.
There are however two differential revisions that needs similar functionality. 
It would be great to decide what implementation to use and make it available as 
a general utility.

The two potential users: http://reviews.llvm.org/D12761 and 
http://reviews.llvm.org/D15227

http://reviews.llvm.org/D15924

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Core/MemRegion.cpp

Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -573,6 +573,19 @@
   return false;
 }
 
+StringRef MemRegion::getVariableName() const {
+  const MemRegion *reg = this;
+  while (const auto *ereg = dyn_cast(reg))
+reg = ereg->getSuperRegion();
+  const auto *vreg = dyn_cast(reg);
+  if (!vreg)
+return "";
+  const auto *nd = dyn_cast(vreg->getDecl());
+  if (!nd)
+return "";
+  return nd->getName();
+}
+
 void MemRegion::printPretty(raw_ostream &os) const {
   assert(canPrintPretty() && "This region cannot be printed pretty.");
   os << "'";
Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -176,6 +176,11 @@
   /// as part of a larger expression.
   virtual bool canPrintPrettyAsExpr() const;
 
+  /// \brief In case this region is a region of a variable or an element 
region,
+  /// this method will return the name of the variable. Otherwise it will 
return
+  /// an empty StringRef.
+  StringRef getVariableName() const;
+
   /// \brief Print the region as expression.
   ///
   /// When this region represents a subexpression, the method is for printing


Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -573,6 +573,19 @@
   return false;
 }
 
+StringRef MemRegion::getVariableName() const {
+  const MemRegion *reg = this;
+  while (const auto *ereg = dyn_cast(reg))
+reg = ereg->getSuperRegion();
+  const auto *vreg = dyn_cast(reg);
+  if (!vreg)
+return "";
+  const auto *nd = dyn_cast(vreg->getDecl());
+  if (!nd)
+return "";
+  return nd->getName();
+}
+
 void MemRegion::printPretty(raw_ostream &os) const {
   assert(canPrintPretty() && "This region cannot be printed pretty.");
   os << "'";
Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -176,6 +176,11 @@
   /// as part of a larger expression.
   virtual bool canPrintPrettyAsExpr() const;
 
+  /// \brief In case this region is a region of a variable or an element region,
+  /// this method will return the name of the variable. Otherwise it will return
+  /// an empty StringRef.
+  StringRef getVariableName() const;
+
   /// \brief Print the region as expression.
   ///
   /// When this region represents a subexpression, the method is for printing
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2016-01-06 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Utility.h:54
@@ +53,3 @@
+/// \returns variable name for memory region
+std::string variableName(const clang::ento::MemRegion *MR);
+

zaks.anna wrote:
> Since this takes no arguments but MemRegion, seems like it could go on 
> MemRegion. Please, submit this as a separate patch.
> 
> 
A different implementation to achieve this functionality is proposed here: 
http://reviews.llvm.org/D15924
The proposed implementation is much lighter and has less functionality, it will 
not print the name of the struct and the index of the array (which might be 
unknown in most of the cases). Does that implementation works for you? Is that 
sufficient? Please review it.


http://reviews.llvm.org/D12761



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


r256937 - [Driver] Add support for -fno-builtin-foo options.

2016-01-06 Thread Chad Rosier via cfe-commits
Author: mcrosier
Date: Wed Jan  6 08:35:46 2016
New Revision: 256937

URL: http://llvm.org/viewvc/llvm-project?rev=256937&view=rev
Log:
[Driver] Add support for -fno-builtin-foo options.

Addresses PR4941 and rdar://6756912.
http://reviews.llvm.org/D15195

Modified:
cfe/trunk/include/clang/Basic/Builtins.h
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/Basic/Builtins.cpp
cfe/trunk/lib/Basic/LangOptions.cpp
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CodeGenOptions.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/2007-04-14-FNoBuiltin.c
cfe/trunk/test/CodeGen/libcalls-complex.c
cfe/trunk/test/CodeGen/libcalls-fno-builtin.c
cfe/trunk/test/CodeGen/nobuiltin.c
cfe/trunk/test/Sema/implicit-builtin-freestanding.c

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=256937&r1=256936&r2=256937&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Wed Jan  6 08:35:46 2016
@@ -192,6 +192,10 @@ public:
   /// for AuxTarget).
   unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSRecords.size(); }
 
+  /// Returns true if this is a libc/libm function without the '__builtin_'
+  /// prefix.
+  static bool isBuiltinFunc(const char *Name);
+
 private:
   const Info &getRecord(unsigned ID) const;
 

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=256937&r1=256936&r2=256937&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Wed Jan  6 08:35:46 2016
@@ -109,6 +109,9 @@ public:
   /// \brief Options for parsing comments.
   CommentOptions CommentOpts;
 
+  /// \brief A list of all -fno-builtin-* function names (e.g., memset).
+  std::vector NoBuiltinFuncs;
+
   /// \brief Triples of the OpenMP targets that the host code codegen should
   /// take into account in order to generate accurate offloading descriptors.
   std::vector OMPTargetTriples;
@@ -142,6 +145,10 @@ public:
   /// \brief Reset all of the options that are not considered when building a
   /// module.
   void resetNonModularOptions();
+
+  /// \brief Is this a libc/libm function that is no longer recognized as a
+  /// builtin because a -fno-builtin-* option has been specified?
+  bool isNoBuiltinFunc(const char *Name) const;
 };
 
 /// \brief Floating point control options

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=256937&r1=256936&r2=256937&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jan  6 08:35:46 2016
@@ -814,7 +814,7 @@ def fno_blocks : Flag<["-"], "fno-blocks
 def fno_borland_extensions : Flag<["-"], "fno-borland-extensions">, 
Group;
 def fno_builtin : Flag<["-"], "fno-builtin">, Group, 
Flags<[CC1Option]>,
   HelpText<"Disable implicit builtin knowledge of functions">;
-def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group,
+def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group, 
Flags<[CC1Option]>,
   HelpText<"Disable implicit builtin knowledge of a specific function">;
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">, Group, 
Flags<[CC1Option]>,
   HelpText<"Disable implicit builtin knowledge of math functions">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=256937&r1=256936&r2=256937&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Wed Jan  6 08:35:46 2016
@@ -218,6 +218,9 @@ public:
   /// Set of sanitizer checks that trap rather than diagnose.
   SanitizerSet SanitizeTrap;
 
+  /// \brief A list of all -fno-builtin-* function names (e.g., memset).
+  std::vector NoBuiltinFuncs;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)
@@ -227,6 +230,14 @@ public:
 #include "clang/Frontend/CodeGenOptions.def"
 
   CodeGenOptions();
+
+  /// \brief Is this a libc/libm function that is no longer recogni

Re: [PATCH] D15448: [analyzer] SVal Visitor.

2016-01-06 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def:31
@@ +30,3 @@
+// is both instantiated and derived from.
+// Additionally, its kind is not its name with "Kind" suffix,
+// unlike all other regions.

zaks.anna wrote:
> I'd rather rename the "Kind" suffix. Is that possible?
> 
> Having REGION and NORMAL_REGION is strange.
In fact, `MemSpaceRegion` is quite special, because it is the only thing in the 
hierarchy that can be both derived from (normally such values are marked as 
"abstract") and instantiated (for which it has a kind defined). Instances of 
MemSpaceRegion are used, at least, for holding some code regions. Probably 
create a new memspace for such regions and remove the kind value?

Ok, i'd go ahead and prepare a separate review for unifying the naming 
convention :)


http://reviews.llvm.org/D15448



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


Re: [PATCH] D15195: PR4941: Add support for -fno-builtin-foo options.

2016-01-06 Thread Chad Rosier via cfe-commits
mcrosier closed this revision.
mcrosier added a comment.

Committed in r256937.  Thanks, Bob.


http://reviews.llvm.org/D15195



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


r256939 - Show inclusions from a preamble in clang_getInclusions.

2016-01-06 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Wed Jan  6 09:12:51 2016
New Revision: 256939

URL: http://llvm.org/viewvc/llvm-project?rev=256939&view=rev
Log:
Show inclusions from a preamble in clang_getInclusions.

When reparsing a translation unit with preamble generation turned on,
no includes are found. This is due to the fact that all SLocs from
AST/PCH files are skipped as they are 'loaded', and inclusions from a
preamble are also 'loaded'. So, in case a file has a preamble, it first
needs to process those loaded inclusions, and then check for any local
inclusions. This latter one is for any includes that are not part of the
preamble, like includes half-way through a file.

This fixes PR24748.

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

Modified:
cfe/trunk/test/Index/cindex-test-inclusions.c
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndexInclusionStack.cpp

Modified: cfe/trunk/test/Index/cindex-test-inclusions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/cindex-test-inclusions.c?rev=256939&r1=256938&r2=256939&view=diff
==
--- cfe/trunk/test/Index/cindex-test-inclusions.c (original)
+++ cfe/trunk/test/Index/cindex-test-inclusions.c Wed Jan  6 09:12:51 2016
@@ -11,3 +11,14 @@
 // CHECK: included by:
 // CHECK: include_test.h:1:10
 // CHECK: cindex-test-inclusions.c:3:10
+
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-inclusion-stack-source %s 
2>&1 | FileCheck -check-prefix=REPARSE %s
+// REPARSE: include_test_2.h
+// REPARSE: included by:
+// REPARSE: include_test.h:1:10
+// REPARSE: cindex-test-inclusions.c:3:10
+// REPARSE: include_test.h
+// REPARSE: included by:
+// REPARSE: cindex-test-inclusions.c:3:10
+// REPARSE: cindex-test-inclusions.c
+// REPARSE: included by:

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=256939&r1=256938&r2=256939&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Jan  6 09:12:51 2016
@@ -1593,6 +1593,8 @@ int perform_test_load_source(int argc, c
   int num_unsaved_files = 0;
   enum CXErrorCode Err;
   int result;
+  unsigned Repeats = 0;
+  unsigned I;
 
   Idx = clang_createIndex(/* excludeDeclsFromPCH */
   (!strcmp(filter, "local") || 
@@ -1609,6 +1611,9 @@ int perform_test_load_source(int argc, c
 return -1;
   }
 
+  if (getenv("CINDEXTEST_EDITING"))
+Repeats = 5;
+
   Err = clang_parseTranslationUnit2(Idx, 0,
 argv + num_unsaved_files,
 argc - num_unsaved_files,
@@ -1622,6 +1627,22 @@ int perform_test_load_source(int argc, c
 return 1;
   }
 
+  for (I = 0; I != Repeats; ++I) {
+if (checkForErrors(TU) != 0)
+  return -1;
+
+if (Repeats > 1) {
+  Err = clang_reparseTranslationUnit(TU, num_unsaved_files, unsaved_files,
+ clang_defaultReparseOptions(TU));
+  if (Err != CXError_Success) {
+describeLibclangFailure(Err);
+free_remapped_files(unsaved_files, num_unsaved_files);
+clang_disposeIndex(Idx);
+return 1;
+  }
+}
+  }
+
   result = perform_test_load(Idx, TU, filter, NULL, Visitor, PV,
  CommentSchemaFile);
   free_remapped_files(unsaved_files, num_unsaved_files);

Modified: cfe/trunk/tools/libclang/CIndexInclusionStack.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexInclusionStack.cpp?rev=256939&r1=256938&r2=256939&view=diff
==
--- cfe/trunk/tools/libclang/CIndexInclusionStack.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexInclusionStack.cpp Wed Jan  6 09:12:51 2016
@@ -21,56 +21,81 @@
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 
-extern "C" {
-void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
- CXClientData clientData) {
-  if (cxtu::isNotUsableTU(TU)) {
-LOG_BAD_TU(TU);
-return;
-  }
-
+static void getInclusions(const SrcMgr::SLocEntry 
&(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
+  CXTranslationUnit TU, CXInclusionVisitor CB,
+  CXClientData clientData)
+{
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   SourceManager &SM = CXXUnit->getSourceManager();
   ASTContext &Ctx = CXXUnit->getASTContext();
-
   SmallVector InclusionStack;
-  unsigned n =  SM.local_sloc_entry_size();
-
-  // In the case where all the SLocEntries are in an external source, traverse
-  // those SLocEntries as well.  This is the case where we are looking
-  // at the inclusion stack of an AST/PCH file.
-  const SrcMgr::SLocEntry &(SourceManager::*G

Re: [PATCH] D14329: Show inclusions from a preamble in clang_getInclusions.

2016-01-06 Thread Erik Verbruggen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256939: Show inclusions from a preamble in 
clang_getInclusions. (authored by erikjv).

Changed prior to commit:
  http://reviews.llvm.org/D14329?vs=39187&id=44120#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14329

Files:
  cfe/trunk/test/Index/cindex-test-inclusions.c
  cfe/trunk/tools/c-index-test/c-index-test.c
  cfe/trunk/tools/libclang/CIndexInclusionStack.cpp

Index: cfe/trunk/tools/libclang/CIndexInclusionStack.cpp
===
--- cfe/trunk/tools/libclang/CIndexInclusionStack.cpp
+++ cfe/trunk/tools/libclang/CIndexInclusionStack.cpp
@@ -21,56 +21,81 @@
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 
-extern "C" {
-void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
- CXClientData clientData) {
-  if (cxtu::isNotUsableTU(TU)) {
-LOG_BAD_TU(TU);
-return;
-  }
-
+static void getInclusions(const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const, unsigned n,
+  CXTranslationUnit TU, CXInclusionVisitor CB,
+  CXClientData clientData)
+{
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   SourceManager &SM = CXXUnit->getSourceManager();
   ASTContext &Ctx = CXXUnit->getASTContext();
-
   SmallVector InclusionStack;
-  unsigned n =  SM.local_sloc_entry_size();
-
-  // In the case where all the SLocEntries are in an external source, traverse
-  // those SLocEntries as well.  This is the case where we are looking
-  // at the inclusion stack of an AST/PCH file.
-  const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsigned, bool*) const;
-  if (n == 1) {
-Getter = &SourceManager::getLoadedSLocEntry;
-n = SM.loaded_sloc_entry_size();
-  } else
-Getter = &SourceManager::getLocalSLocEntry;
+  const bool HasPreamble = SM.getPreambleFileID().isValid();
 
   for (unsigned i = 0 ; i < n ; ++i) {
 bool Invalid = false;
 const SrcMgr::SLocEntry &SL = (SM.*Getter)(i, &Invalid);
-
+
 if (!SL.isFile() || Invalid)
   continue;
 
 const SrcMgr::FileInfo &FI = SL.getFile();
 if (!FI.getContentCache()->OrigEntry)
   continue;
-
-// Build the inclusion stack.
+
+// If this is the main file, and there is a preamble, skip this SLoc. The
+// inclusions of the preamble already showed it.
 SourceLocation L = FI.getIncludeLoc();
+if (HasPreamble && CXXUnit->isInMainFileID(L))
+  continue;
+
+// Build the inclusion stack.
 InclusionStack.clear();
 while (L.isValid()) {
   PresumedLoc PLoc = SM.getPresumedLoc(L);
   InclusionStack.push_back(cxloc::translateSourceLocation(Ctx, L));
   L = PLoc.isValid()? PLoc.getIncludeLoc() : SourceLocation();
 }
-
+
+// If there is a preamble, the last entry is the "inclusion" of that
+// preamble into the main file, which has the bogus entry of main.c:1:1
+if (HasPreamble && !InclusionStack.empty())
+  InclusionStack.pop_back();
+
 // Callback to the client.
 // FIXME: We should have a function to construct CXFiles.
 CB(static_cast(
- const_cast(FI.getContentCache()->OrigEntry)), 
+ const_cast(FI.getContentCache()->OrigEntry)),
InclusionStack.data(), InclusionStack.size(), clientData);
-  }
+  }
+}
+
+
+extern "C" {
+void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
+ CXClientData clientData) {
+  if (cxtu::isNotUsableTU(TU)) {
+LOG_BAD_TU(TU);
+return;
+  }
+
+  SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
+  const unsigned n =  SM.local_sloc_entry_size();
+
+  // In the case where all the SLocEntries are in an external source, traverse
+  // those SLocEntries as well.  This is the case where we are looking
+  // at the inclusion stack of an AST/PCH file. Also, if we are not looking at
+  // a AST/PCH file, but this file has a pre-compiled preamble, we also need
+  // to look in that file.
+  if (n == 1 || SM.getPreambleFileID().isValid()) {
+getInclusions(&SourceManager::getLoadedSLocEntry,
+  SM.loaded_sloc_entry_size(), TU, CB, clientData);
+  }
+
+  // Not a PCH/AST file. Note, if there is a preamble, it could still be that
+  // there are #includes in this file (e.g. for any include after the first
+  // declaration).
+  if (n != 1)
+getInclusions(&SourceManager::getLocalSLocEntry, n, TU, CB, clientData);
+
 }
 } // end extern C
Index: cfe/trunk/tools/c-index-test/c-index-test.c
===
--- cfe/trunk/tools/c-index-test/c-index-test.c
+++ cfe/trunk/tools/c-index-test/c-index-test.c
@@ -1593,6 +1593,8 @@
   int num_unsaved_files = 0;
   enum CXErrorCode Err;
   int result;
+  unsigned Repeats = 0;
+  unsigned I;
 
   Idx = clang_createIndex(/* excludeDeclsFromPCH */
   (!strcmp

[PATCH] D15926: Do not print certain warnings when input is a header.

2016-01-06 Thread Erik Verbruggen via cfe-commits
erikjv created this revision.
erikjv added reviewers: klimek, rsmith.
erikjv added a subscriber: cfe-commits.

When generating pre-compiled headers, or when opening a header file with
libclang, suppress the warnings "#pragma once in main file" and
"#include_next in primary source file".

Fixes PR16686 and PR24390.


http://reviews.llvm.org/D15926

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Frontend/FrontendOptions.h
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Lex/PPDirectives.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Lex/Pragma.cpp
  test/Preprocessor/header_is_main_file.c

Index: test/Preprocessor/header_is_main_file.c
===
--- /dev/null
+++ test/Preprocessor/header_is_main_file.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -x c-header -ffreestanding -Eonly -verify %s
+// expected-no-diagnostics
+
+#pragma once
+#include_next "stdint.h"
+#if !__has_include_next("stdint.h")
+#error "__has_include_next failed"
+#endif
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -354,7 +354,9 @@
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
 ///
 void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
-  if (isInPrimaryFile()) {
+  // If the main file is a header, then it's either for PCH/AST generation,
+  // or libclang opened it. Allow #pragma once either way.
+  if (isInPrimaryFile() && !SourceMgr.isMainFileHeader()) {
 Diag(OnceTok, diag::pp_pragma_once_in_main_file);
 return;
   }
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1389,7 +1389,10 @@
   // Preprocessor::HandleIncludeNextDirective.
   const DirectoryLookup *Lookup = PP.GetCurDirLookup();
   const FileEntry *LookupFromFile = nullptr;
-  if (PP.isInPrimaryFile()) {
+  if (PP.isInPrimaryFile() && PP.getSourceManager().isMainFileHeader()) {
+// If the main file is a header, then it's either for PCH/AST generation,
+// or libclang opened it. Either way, handle it as a normal include below.
+  } else if (PP.isInPrimaryFile()) {
 Lookup = nullptr;
 PP.Diag(Tok, diag::pp_include_next_in_primary);
   } else if (PP.getCurrentSubmodule()) {
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1834,7 +1834,10 @@
   // diagnostic.
   const DirectoryLookup *Lookup = CurDirLookup;
   const FileEntry *LookupFromFile = nullptr;
-  if (isInPrimaryFile()) {
+  if (isInPrimaryFile() && SourceMgr.isMainFileHeader()) {
+// If the main file is a header, then it's either for PCH/AST generation,
+// or libclang opened it. Either way, handle it as a normal include below.
+  } else if (isInPrimaryFile()) {
 Lookup = nullptr;
 Diag(IncludeNextTok, diag::pp_include_next_in_primary);
   } else if (CurSubmodule) {
Index: lib/Frontend/FrontendActions.cpp
===
--- lib/Frontend/FrontendActions.cpp
+++ lib/Frontend/FrontendActions.cpp
@@ -375,7 +375,7 @@
Module::getModuleInputBufferName());
   // Ownership of InputBuffer will be transferred to the SourceManager.
   setCurrentInput(FrontendInputFile(InputBuffer.release(), getCurrentFileKind(),
-Module->IsSystem));
+false, Module->IsSystem));
   return true;
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1141,6 +1141,7 @@
   }
 
   InputKind DashX = IK_None;
+  bool IsHeader = false;
   if (const Arg *A = Args.getLastArg(OPT_x)) {
 DashX = llvm::StringSwitch(A->getValue())
   .Case("c", IK_C)
@@ -1168,6 +1169,13 @@
 if (DashX == IK_None)
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
+IsHeader = llvm::StringSwitch(A->getValue())
+.Case("c-header", true)
+.Case("cl-header", true)
+.Case("objective-c-header", true)
+.Case("c++-header", true)
+.Case("objective-c++-header", true)
+.Default(false);
   }
 
   // '-' is the default input if none is given.
@@ -1184,7 +1192,7 @@
   if (i == 0)
 DashX = IK;
 }
-Opts.Inputs.emplace_back(std::move(Inputs[i]), IK);
+Opts.Inputs.emplace_back(std::move(Inputs[i]), IK, IsHeader);
   }
 
   return DashX;
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -724,6 +724,7 @@

Re: [PATCH] D7606: Fix adress cast for C++ in SEMA

2016-01-06 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 44124.
sfantao added a comment.

Rebase.


http://reviews.llvm.org/D7606

Files:
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  test/CodeGen/address-space-explicit-cast.c

Index: test/CodeGen/address-space-explicit-cast.c
===
--- /dev/null
+++ test/CodeGen/address-space-explicit-cast.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -x c %s | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -emit-llvm -o - -x c++ %s | FileCheck 
-check-prefix=CHECK-CXX %s
+
+typedef __attribute__((address_space(1))) char *AddrSpaceCharType;
+
+// CHECK-LABEL: @foo()
+// CHECK-CXX-LABEL: @_Z3foov()
+void foo() {
+  // CHECK: %p = alloca i8 addrspace(1)*
+  // CHECK-CXX: %p = alloca i8 addrspace(1)*
+  AddrSpaceCharType p;
+
+  // CHECK: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), 
i8 addrspace(1)** %p
+  // CHECK-CXX: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 
addrspace(1)*), i8 addrspace(1)** %p
+  p = (AddrSpaceCharType) "a";
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2040,7 +2040,7 @@
   << OpRange;
 return TC_Success;
   }
-  
+
   // C++ 5.2.10p7: A pointer to an object can be explicitly converted to
   //   a pointer to an object of different type.
   // Void pointers are not specified, but supported by every compiler out 
there.
@@ -2108,6 +2108,22 @@
   return;
 }
 
+  // If we are casting pointers, we need to check whether this refers to an
+  // address space cast.
+  if (DestType->isPointerType() && SrcExpr.get()->getType()->isPointerType()) {
+QualType DTy =
+Self.getASTContext().getCanonicalType(DestType->getPointeeType());
+QualType STy = Self.getASTContext().getCanonicalType(
+SrcExpr.get()->getType()->getPointeeType());
+// If the pointer point to the same type in different address spaces, this
+// is an address-space cast.
+if (STy.getTypePtr() == DTy.getTypePtr() &&
+STy.getAddressSpace() != DTy.getAddressSpace()) {
+  Kind = CK_AddressSpaceConversion;
+  return;
+}
+  }
+
   // C++ [expr.cast]p5: The conversions performed by
   //   - a const_cast,
   //   - a static_cast,
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -394,6 +394,14 @@
   if (ExprTy == TypeTy)
 return E;
 
+  // In the event an address space cast is requested, the kind passed from the
+  // caller should not be CK_NoOp.
+  assert((Kind != CK_NoOp ||
+  !(ExprTy->isPointerType() && TypeTy->isPointerType() &&
+ExprTy->getPointeeType().getAddressSpace() !=
+TypeTy->getPointeeType().getAddressSpace())) &&
+ "NoOp is not a valid kind for and address cast");
+
   if (ImplicitCastExpr *ImpCast = dyn_cast(E)) {
 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
   ImpCast->setType(Ty);


Index: test/CodeGen/address-space-explicit-cast.c
===
--- /dev/null
+++ test/CodeGen/address-space-explicit-cast.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -x c %s | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -emit-llvm -o - -x c++ %s | FileCheck -check-prefix=CHECK-CXX %s
+
+typedef __attribute__((address_space(1))) char *AddrSpaceCharType;
+
+// CHECK-LABEL: @foo()
+// CHECK-CXX-LABEL: @_Z3foov()
+void foo() {
+  // CHECK: %p = alloca i8 addrspace(1)*
+  // CHECK-CXX: %p = alloca i8 addrspace(1)*
+  AddrSpaceCharType p;
+
+  // CHECK: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), i8 addrspace(1)** %p
+  // CHECK-CXX: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), i8 addrspace(1)** %p
+  p = (AddrSpaceCharType) "a";
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2040,7 +2040,7 @@
   << OpRange;
 return TC_Success;
   }
-  
+
   // C++ 5.2.10p7: A pointer to an object can be explicitly converted to
   //   a pointer to an object of different type.
   // Void pointers are not specified, but supported by every compiler out there.
@@ -2108,6 +2108,22 @@
   return;
 }
 
+  // If we are casting pointers, we need to check whether this refers to an
+  // address space cast.
+  if (DestType->isPointerType() && SrcExpr.get()->getType()->isPointerType()) {
+QualType DTy =
+Self.getASTContext().getCanonicalType(DestType->getPointeeType());
+QualType STy = Self.getASTContext().getCanonicalType(
+SrcExpr.get()->getType()->getPointeeType());
+// If the pointer point to the same type in different address spaces, this
+// is an address-space cast.
+if (STy.getTypePtr() == DTy.getTypePtr() &&
+STy.

Re: [PATCH] D15924: [analyzer] Utility to extract the variable name from a memory region.

2016-01-06 Thread Alexander Droste via cfe-commits
Alexander_Droste added inline comments.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:586
@@ +585,3 @@
+return "";
+  return nd->getName();
+}

Isn't calling `getDecl()` and `getName()` afterwards identical to 
`printPretty()`?
Is it possible that a `NamedDecl` cannot be obtained from a `DeclRegion`?


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:588
@@ -576,1 +587,3 @@
+}
+
 void MemRegion::printPretty(raw_ostream &os) const {

Regarding the MPI-Checker patch http://reviews.llvm.org/D12761 it is 
insufficient 
if the array index (if obtainable) is not provided. 
I think it would be nice if a `getVariableName` function could always provide 
as much
information as possible, regarding the passed memory region. Do you actually 
see a case in 
the other implementation where this function fails?
The index is a member variable of the `ElementRegion` why obtaining that
value cannot fail. If the memory region passed is no `ElementRegion` then 
simply `printPretty()` is called. I could submit the patch right away if this 
helps.





http://reviews.llvm.org/D15924



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


Re: [PATCH] D15853: [PGO]: Simplify coverage data lowering code

2016-01-06 Thread David Li via cfe-commits
davidxl updated this revision to Diff 44127.
davidxl added a comment.

Update patch to reduce overhead: Only record names for unused functions.


http://reviews.llvm.org/D15853

Files:
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  lib/CodeGen/CoverageMappingGen.h

Index: lib/CodeGen/CoverageMappingGen.h
===
--- lib/CodeGen/CoverageMappingGen.h
+++ lib/CodeGen/CoverageMappingGen.h
@@ -54,6 +54,7 @@
   CoverageSourceInfo &SourceInfo;
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionRecords;
+  std::vector FunctionNames;
   llvm::StructType *FunctionRecordTy;
   std::string CoverageMappings;
 
@@ -70,7 +71,8 @@
   void addFunctionMappingRecord(llvm::GlobalVariable *FunctionName,
 StringRef FunctionNameValue,
 uint64_t FunctionHash,
-const std::string &CoverageMapping);
+const std::string &CoverageMapping,
+bool isUsed = true);
 
   /// \brief Emit the coverage mapping data for a translation unit.
   void emit();
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -910,11 +910,11 @@
 }
 
 void CoverageMappingModuleGen::addFunctionMappingRecord(
-llvm::GlobalVariable *NamePtr, StringRef NameValue,
-uint64_t FuncHash, const std::string &CoverageMapping) {
+llvm::GlobalVariable *NamePtr, StringRef NameValue, uint64_t FuncHash,
+const std::string &CoverageMapping, bool isUsed) {
   llvm::LLVMContext &Ctx = CGM.getLLVMContext();
   if (!FunctionRecordTy) {
-#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) LLVMType,
+#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) LLVMType,
 llvm::Type *FunctionRecordTypes[] = {
   #include "llvm/ProfileData/InstrProfData.inc"
 };
@@ -929,6 +929,9 @@
   };
   FunctionRecords.push_back(llvm::ConstantStruct::get(
   FunctionRecordTy, makeArrayRef(FunctionRecordVals)));
+  if (!isUsed)
+FunctionNames.push_back(
+llvm::ConstantExpr::getBitCast(NamePtr, 
llvm::Type::getInt8PtrTy(Ctx)));
   CoverageMappings += CoverageMapping;
 
   if (CGM.getCodeGenOpts().DumpCoverageMapping) {
@@ -1023,6 +1026,17 @@
 
   // Make sure the data doesn't get deleted.
   CGM.addUsedGlobal(CovData);
+  // Create the deferred function records array
+  if (!FunctionNames.empty()) {
+auto NamesArrTy = llvm::ArrayType::get(llvm::Type::getInt8PtrTy(Ctx),
+   FunctionNames.size());
+auto NamesArrVal = llvm::ConstantArray::get(NamesArrTy, FunctionNames);
+// This variable will *NOT* be emitted to the object file. It is used
+// to pass the list of names referenced to codegen.
+new llvm::GlobalVariable(CGM.getModule(), NamesArrTy, true,
+ llvm::GlobalValue::InternalLinkage, NamesArrVal,
+ llvm::getCoverageNamesVarName());
+  }
 }
 
 unsigned CoverageMappingModuleGen::getFileID(const FileEntry *File) {
Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -699,7 +699,7 @@
 
   setFuncName(Name, Linkage);
   CGM.getCoverageMapping()->addFunctionMappingRecord(
-  FuncNameVar, FuncName, FunctionHash, CoverageMapping);
+  FuncNameVar, FuncName, FunctionHash, CoverageMapping, false);
 }
 
 void CodeGenPGO::computeRegionCounts(const Decl *D) {


Index: lib/CodeGen/CoverageMappingGen.h
===
--- lib/CodeGen/CoverageMappingGen.h
+++ lib/CodeGen/CoverageMappingGen.h
@@ -54,6 +54,7 @@
   CoverageSourceInfo &SourceInfo;
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionRecords;
+  std::vector FunctionNames;
   llvm::StructType *FunctionRecordTy;
   std::string CoverageMappings;
 
@@ -70,7 +71,8 @@
   void addFunctionMappingRecord(llvm::GlobalVariable *FunctionName,
 StringRef FunctionNameValue,
 uint64_t FunctionHash,
-const std::string &CoverageMapping);
+const std::string &CoverageMapping,
+bool isUsed = true);
 
   /// \brief Emit the coverage mapping data for a translation unit.
   void emit();
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -910,11 +910,11 @@
 }
 
 void CoverageMappingModuleGen::addFunctionMappingRecord(
-llvm::GlobalVariable *NamePtr, StringRef NameValue,
-uint64_t FuncHash, const std::string &CoverageMapping) {
+llvm::GlobalVariable *NamePtr, Stri

Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-06 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4283
@@ +4282,3 @@
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(notMatchesC("void f();", functionProtoType()));

aaron.ballman wrote:
> > I don't understand what would be tested by adding a test for 
> > parameterCountIs() on a function that doesn't have a prototype since it is 
> > a nested matcher passed to functionProtoType() and since the function 
> > doesn't have a prototype, that outer matcher won't match.
> 
> Not according to the AST matcher that was implemented -- it supports 
> FunctionProtoType and FunctionDecl. I want to make sure that if you get to 
> parameterCountIs() through functionDecl() that it doesn't fail.
Ah, OK, you were asking for a test on `functionDecl`, not `functionProtoType`.  
I can do that.  I guess what threw me off is that the comment was attached to 
the prototype tests.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4992
@@ +4991,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",

aaron.ballman wrote:
> > I'm happy to make the improvement, but I don't know how. I simply call the 
> > Node.underlyingType(), just like hasType calls Node.getType(). I don't know 
> > why they are different.
> 
> hasType() and hasUnderlyingType() have different operational semantic 
> implications, at least to me. hasType() asks, "ultimately, what is the type 
> of this thing?", and Node.underlyingType() answers that. To me, 
> hasUnderlyingType() asks, "in the chain of types that this typedef refers to, 
> does this thing match any of them?", and Node.underlyingType() does not 
> answer that -- it only looks at the final desugared type. The difference we 
> want is that hasType() continues to look at the final type, but 
> hasUnderlyingType() needs to do more work to look at intermediary types and 
> terminate that loop when the answer is "yes, it has this type" or "no, we 
> can't desugar any further."
> 
> If we don't care about the intermediate types for your needs, then I don't 
> see the point to hasUnderlyingType() being an AST matcher at all. hasType() 
> does exactly what is needed, and you can instead modify that to accept a 
> TypedefDecl in addition to Expr and ValueDecl. However, I still see value in 
> hasUnderlyingType() because typedef chains can be long and complex (like in 
> the Win32 APIs), and being able to query for intermediary types would be 
> useful. e.g., I want to know about all types that have an intermediary type 
> of DWORD (which itself is a typedef for an unsigned integer type). hasType() 
> will always go to the final type, making such a matcher impossible without 
> something like hasUnderlyingType().
I just named the matcher after the 
[accessor](http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html#a5fccedff6d3854db365a540145029158)
 on a typedefDecl node.  To me it's just a narrowing matcher on that node that 
gives you access to whatever the accessor returns.

Things may have changed in the meantime, but when I originally created this 
patch you couldn't do `typedefDecl(hasType(asString("int")))`.  It doesn't 
compile.  Since `hasType` just matched against the value of whatever 
`Node.getType()` returned it seemed natural to add a matcher called 
`hasUnderlyingType` that just matched against the value of whatever 
`Node.getUnderlyingType()` returned.

As I said, I'm happy to make the suggested improvement, but beyond simple 
immitation of existing matchers, I have no idea how to traverse the encodings 
of types within the guts of clang.  This is what I mean when I say "I don't 
know how".  I understand conceptually what you are saying but I have no idea 
how to express that in clang's code base.


http://reviews.llvm.org/D8149



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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Jason Henline via cfe-commits
jhen updated this revision to Diff 44131.
jhen added a reviewer: jlebar.
jhen removed a subscriber: jlebar.
jhen added a comment.

- Correct dependence info in CUDA kernel call AST

  This patch removes the propagation of type and value dependence and the 
propagation of information on unexpanded parameter packs from the CUDA kernel 
configuration function call expression to its parent CUDA kernel call 
expression AST node. It does, however, maintain the propagation of 
instantiation dependence between those nodes, as introduced in the previous 
revision of this patch.

  The last patch should not have propagated value and type dependence from the 
CUDA kernel config function to the entire CUDA kernel call expression AST node. 
 The reason is that the CUDA kernel call expression has a void value, so it's 
value cannot depend on template types or values, it is always simply void.

  However, the CUDA kernel call expression node can contain template arguments, 
so it can be instantiation dependent.  That means that the instantiation 
dependence should be propagated from the config call to the kernel call node. 
The instantiation dependence propagation is also sufficient to fix the crashing 
bug that results from using an undeclared identifier as a config argument.

  As for tracking unexpanded parameter packs, it is not yet clear how the CUDA 
triple-angle-bracket syntax will interoperate with variadic templates, so I 
will leave that propagation out of this patch and it can be dealt with later.


http://reviews.llvm.org/D15858

Files:
  include/clang/AST/ExprCXX.h
  test/SemaCUDA/kernel-call.cu

Index: test/SemaCUDA/kernel-call.cu
===
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
 
   int (*fp)(int) = h2;
   fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -171,7 +171,11 @@
 return cast_or_null(getPreArg(CONFIG));
   }
   CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
-  void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
+  void setConfig(CallExpr *E) {
+setPreArg(CONFIG, E);
+setInstantiationDependent(isInstantiationDependent() ||
+  E->isInstantiationDependent());
+  }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CUDAKernelCallExprClass;


Index: test/SemaCUDA/kernel-call.cu
===
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
 
   int (*fp)(int) = h2;
   fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
 }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -171,7 +171,11 @@
 return cast_or_null(getPreArg(CONFIG));
   }
   CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
-  void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
+  void setConfig(CallExpr *E) {
+setPreArg(CONFIG, E);
+setInstantiationDependent(isInstantiationDependent() ||
+  E->isInstantiationDependent());
+  }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CUDAKernelCallExprClass;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Driver/ToolChains.cpp:4125
@@ +4124,3 @@
+  ArgStringList &LDArgs) const {
+  if (DriverArgs.hasArg(options::OPT_nocudalib) || !CudaInstallation.isValid())
+return;

tra wrote:
> I'd rename -nocudalib to -nocudalibdevice (or -nocudabclib) to better reflect 
> what it currently does -- disables linking with CUDA's libdevice bitcode.
> 
> Then you could use -nocudalib to control automatic addition of CUDA 
> library-related options which would be closer to what '-nostdlib' does.
> 
> While you're at it, you may consider adding linker flags to link with static 
> libcudart. nvcc always adds "-lcudart_static  -lrt -lpthread  -ldl" at the 
> end. If user explicitly requests linking with dynamic version of libcudart, 
> then it gets linked first, and linker then ignores all the symbols from 
> static lib.
> 
Sounds like a plan.  I'll send separate patches for each of these.


http://reviews.llvm.org/D15596



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


r256956 - Bump DiagnosticDriverKinds count; we're close to hitting it.

2016-01-06 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Wed Jan  6 12:43:14 2016
New Revision: 256956

URL: http://llvm.org/viewvc/llvm-project?rev=256956&view=rev
Log:
Bump DiagnosticDriverKinds count; we're close to hitting it.

 $ grep '= DIAG_START_DRIVER' include/clang/Basic/DiagnosticIDs.h
   DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  100,
 $ grep 'def ' include/clang/Basic/DiagnosticDriverKinds.td | wc -l
   98

Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=256956&r1=256955&r2=256956&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Wed Jan  6 12:43:14 2016
@@ -29,7 +29,7 @@ namespace clang {
 enum {
   DIAG_START_COMMON= 0,
   DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  100,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
   DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
   DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
   DIAG_START_PARSE = DIAG_START_LEX +  300,


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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Looks sane to me, although I have no idea what I'm doing here; you should 
probably get someone else's approval.


http://reviews.llvm.org/D15858



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


[PATCH] D15928: Add -Wfor-loop-analysis to -Wall.

2016-01-06 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: rtrieu.
thakis added a subscriber: cfe-commits.

Every time I try this warning, it finds a few bugs (I think about 4 total in 
Chromium so far), with 0 false positives. I couldn't measure any build 
performance degradation when turning it on; I tried building clang itself with 
and without the warning, and a small-ish target in chromium (1.6k TUs).

It should be in -Wall, and possibly even make its way into a default warning at 
some point.

http://reviews.llvm.org/D15928

Files:
  include/clang/Basic/DiagnosticGroups.td

Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -616,6 +616,7 @@
 CharSubscript,
 Comment,
 DeleteNonVirtualDtor,
+ForLoopAnalysis,
 Format,
 Implicit,
 InfiniteRecursion,


Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -616,6 +616,7 @@
 CharSubscript,
 Comment,
 DeleteNonVirtualDtor,
+ForLoopAnalysis,
 Format,
 Implicit,
 InfiniteRecursion,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Jason Henline via cfe-commits
jhen added inline comments.


Comment at: test/SemaCUDA/kernel-call.cu:27
@@ -26,1 +26,3 @@
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }

Thanks for bringing this up. While trying to find tests that dealt with each 
dependence individually, I came to realize that value and type dependence 
should not be set for the CUDAKernelCallExpr node because it's value is always 
void. So, I removed the propagation of those two dependencies.

Then, while looking for a test that could handle the parameter pack 
information, I realized that it was opening up a whole new can of worms and 
that the triple-angle-bracket syntax does not currently support variadic 
templates. I decided that parameter packs should be handled as a separate bug, 
so I removed them from this patch.

The instantiation dependence propagation is still valid, though, because it 
just represents whether a template parameter is present anywhere in the 
expression, so I left it in. Correctly tracking instantiation dependence in 
enough to fix the bug this patch was meant to fix, so I think it is the only 
change that should be made in this patch.


http://reviews.llvm.org/D15858



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


Re: [PATCH] D15926: Do not print certain warnings when input is a header.

2016-01-06 Thread Mehdi AMINI via cfe-commits
joker.eph added a subscriber: joker.eph.


Comment at: include/clang/Basic/SourceManager.h:660
@@ -659,1 +659,3 @@
 
+  bool MainFileIsHeader = false;
+

Document?


Comment at: include/clang/Basic/SourceManager.h:764
@@ -761,1 +763,3 @@
 
+  void setMainFileHeader(bool mainFileIsHeader) {
+MainFileIsHeader = mainFileIsHeader;

Variable should start with a capital


Comment at: include/clang/Frontend/FrontendOptions.h:91
@@ -90,1 +90,3 @@
 
+  bool IsHeader;
+

Document


http://reviews.llvm.org/D15926



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


r256960 - Fix -Wdocumentation warning after r256933

2016-01-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Jan  6 13:13:49 2016
New Revision: 256960

URL: http://llvm.org/viewvc/llvm-project?rev=256960&view=rev
Log:
Fix -Wdocumentation warning after r256933

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=256960&r1=256959&r2=256960&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Wed Jan  6 13:13:49 2016
@@ -955,7 +955,7 @@ public:
   /// \brief Emit the target regions enclosed in \a GD function definition or
   /// the function itself in case it is a valid device function. Returns true 
if
   /// \a GD was dealt with successfully.
-  /// \param FD Function to scan.
+  /// \param GD Function to scan.
   virtual bool emitTargetFunctions(GlobalDecl GD);
 
   /// \brief Emit the global variable if it is a valid device global variable.


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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: include/clang/AST/ExprCXX.h:175
@@ +174,3 @@
+  void setConfig(CallExpr *E) {
+setPreArg(CONFIG, E);
+setInstantiationDependent(isInstantiationDependent() ||

Can you assert that the argument is only set once here? (If we set it to 
something instantiation-dependent and then to something that isn't 
instantiation-dependent, we'd compute the wrong instantiation-dependence flag.) 
This function should only be called by the normal constructor and by people who 
called the `EmptyShell` constructor.


Comment at: test/SemaCUDA/kernel-call.cu:27
@@ -26,1 +26,3 @@
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }

jhen wrote:
> Thanks for bringing this up. While trying to find tests that dealt with each 
> dependence individually, I came to realize that value and type dependence 
> should not be set for the CUDAKernelCallExpr node because it's value is 
> always void. So, I removed the propagation of those two dependencies.
> 
> Then, while looking for a test that could handle the parameter pack 
> information, I realized that it was opening up a whole new can of worms and 
> that the triple-angle-bracket syntax does not currently support variadic 
> templates. I decided that parameter packs should be handled as a separate 
> bug, so I removed them from this patch.
> 
> The instantiation dependence propagation is still valid, though, because it 
> just represents whether a template parameter is present anywhere in the 
> expression, so I left it in. Correctly tracking instantiation dependence in 
> enough to fix the bug this patch was meant to fix, so I think it is the only 
> change that should be made in this patch.
What happens if an unexpanded pack is used within the kernel arguments of a 
CUDA kernel call? Do we already reject that? Are there tests for that somewhere?


http://reviews.llvm.org/D15858



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


Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-06 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:309
@@ -286,1 +308,3 @@
 
+  /// \brief Returns true if the CallEvent is call to a function that matches
+  /// the CallDescription.

"is call" -> "is a call"


Comment at: lib/StaticAnalyzer/Core/CheckerContext.cpp:41
@@ +40,3 @@
+  const CallDescription &CD) {
+  assert(Call.getKind() != CE_ObjCMessage);
+  if (!CD.II)

Please, add && "ObjC Methods are not supported"


Comment at: lib/StaticAnalyzer/Core/CheckerContext.cpp:47
@@ +46,3 @@
+return false;
+  return Call.getCalleeIdentifier() == CD.II;
+}

You can micro optimize by checking if the identifier matches first (and only 
checking arguments later); in most cases it won't.


Comment at: lib/StaticAnalyzer/Core/CheckerContext.cpp:57
@@ +56,3 @@
+return false;
+  return Call.getSelector() == getASTContext().Selectors.getSelector(0, 
&CD.II);
+}

This will only match against the first part of the ObjC method name. Also, this 
is not tested. I am Ok with adding the ObjC support later and adding an assert 
above to error out if this is used for ObjC.


http://reviews.llvm.org/D15921



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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Jason Henline via cfe-commits
jhen marked 2 inline comments as done.
jhen added a comment.

http://reviews.llvm.org/D15858



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


r256962 - Module debugging: Defer emitting tag types until their definition

2016-01-06 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Jan  6 13:22:19 2016
New Revision: 256962

URL: http://llvm.org/viewvc/llvm-project?rev=256962&view=rev
Log:
Module debugging: Defer emitting tag types until their definition
was visited and all decls have been merged.

We only get a single chance to emit the types for virtual classes because
CGDebugInfo::completeRequiredType() categorically doesn't complete them.

Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/Inputs/DebugCXX.h
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=256962&r1=256961&r2=256962&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  6 
13:22:19 2016
@@ -59,8 +59,10 @@ class PCHContainerGenerator : public AST
   struct DebugTypeVisitor : public RecursiveASTVisitor {
 clang::CodeGen::CGDebugInfo &DI;
 ASTContext &Ctx;
-DebugTypeVisitor(clang::CodeGen::CGDebugInfo &DI, ASTContext &Ctx)
-: DI(DI), Ctx(Ctx) {}
+bool SkipTagDecls;
+DebugTypeVisitor(clang::CodeGen::CGDebugInfo &DI, ASTContext &Ctx,
+ bool SkipTagDecls)
+: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
 
 /// Determine whether this type can be represented in DWARF.
 static bool CanRepresent(const Type *Ty) {
@@ -75,6 +77,12 @@ class PCHContainerGenerator : public AST
 }
 
 bool VisitTypeDecl(TypeDecl *D) {
+  // TagDecls may be deferred until after all decls have been merged and we
+  // know the complete type. Pure forward declarations will be skipped, but
+  // they don't need to be emitted into the module anyway.
+  if (SkipTagDecls && isa(D))
+  return true;
+
   QualType QualTy = Ctx.getTypeDeclType(D);
   if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
 DI.getOrCreateStandaloneType(QualTy, D->getLocation());
@@ -165,7 +173,7 @@ public:
 // Collect debug info for all decls in this group.
 for (auto *I : D)
   if (!I->isFromASTFile()) {
-DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
+DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
 DTV.TraverseDecl(I);
   }
 return true;
@@ -179,6 +187,11 @@ public:
 if (Diags.hasErrorOccurred())
   return;
 
+if (D->isFromASTFile())
+  return;
+
+DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
+DTV.TraverseDecl(D);
 Builder->UpdateCompletedType(D);
   }
 

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256962&r1=256961&r2=256962&view=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  6 13:22:19 2016
@@ -50,3 +50,9 @@ namespace DebugCXX {
   typedef A B;
   void foo(B) {}
 }
+
+// Virtual class with a forward declaration.
+class FwdVirtual;
+class FwdVirtual {
+  virtual ~FwdVirtual() {}
+};

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=256962&r1=256961&r2=256962&view=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Wed Jan  6 13:22:19 2016
@@ -7,13 +7,11 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps 
-DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll 
-mllvm -debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
-// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
-fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
-debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
-// RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
 
 #ifdef MODULES
 @import DebugCXX;
@@ -23,22 +21,32 @@
 // CHECK-SAME:isOptimized: false,
 // CHECK-SAME-NOT:splitDebugFilename:
 // CHECK-DWO: dwoId:
+
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum"
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
 // CHECK: !DINamespace(name: "DebugCXX"
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
 // CH

r256963 - Fix a typo.

2016-01-06 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Jan  6 13:22:23 2016
New Revision: 256963

URL: http://llvm.org/viewvc/llvm-project?rev=256963&view=rev
Log:
Fix a typo.

Modified:
cfe/trunk/test/Modules/Inputs/DebugCXX.h

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256963&r1=256962&r2=256963&view=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  6 13:22:23 2016
@@ -17,7 +17,7 @@ namespace DebugCXX {
 e2 = '2'
   };
 
-  // Templates (instatiations).
+  // Templates (instantiations).
   template struct traits {};
   template


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


Re: [PATCH] D12901: [Static Analyzer] Assertion "System is over constrained" after truncating 64 bits integers to 32 bits. (PR25078)

2016-01-06 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> This patch also fixes a bug in 'RangeSet::pin' causing single value ranges to 
> not be considered conventionally ordered.


Can that fix be submitted as a separate patch? Is there a test for it?



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:351
@@ -351,1 +350,3 @@
   }
+  case CK_IntegralCast: {
+// Delegate to SValBuilder to process.

SValBuilder::evalCast and SimpleSValBuilder::evalCastFromNonLoc perform a lot 
of special casing. I am not sure we are not loosing anything if we bypass them. 
For example, there is special handling of Booleans. We might want to add this 
smarter handling of the integral conversions inside 
SimpleSValBuilder::evalCastFromNonLoc, where you see the comment starting with 
"If the types are the same or both are integers, ignore the cast."


http://reviews.llvm.org/D12901



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


Re: r252960 - [modules] Simplify and generalize the existing rule for finding hidden

2016-01-06 Thread Adrian Prantl via cfe-commits

> On Jan 5, 2016, at 6:56 PM, Richard Smith  wrote:
> 
> On Tue, Jan 5, 2016 at 1:32 PM, Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> > On Dec 16, 2015, at 5:19 PM, Bob Wilson via cfe-commits 
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> >> On Nov 12, 2015, at 2:19 PM, Richard Smith via cfe-commits 
> >> mailto:cfe-commits@lists.llvm.org>> wrote:
> >>
> >> Author: rsmith
> >> Date: Thu Nov 12 16:19:45 2015
> >> New Revision: 252960
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=252960&view=rev 
> >> 
> >> Log:
> >> [modules] Simplify and generalize the existing rule for finding hidden
> >> declarations in redeclaration lookup. A declaration is now visible to
> >> lookup if:
> >>
> >> * It is visible (not in a module, or in an imported module), or
> >> * We're doing redeclaration lookup and it's externally-visible, or
> >> * We're doing typo correction and looking for unimported decls.
> >>
> >> We now support multiple modules having different internal-linkage or 
> >> no-linkage
> >> definitions of the same name for all entities, not just for functions,
> >> variables, and some typedefs. As previously, if multiple such entities are
> >> visible, any attempt to use them will result in an ambiguity error.
> >>
> >> This patch fixes the linkage calculation for a number of entities where we
> >> previously didn't need to get it right (using-declarations, namespace 
> >> aliases,
> >> and so on).  It also classifies enumerators as always having no linkage, 
> >> which
> >> is a slight deviation from the C++ standard's definition, but not an 
> >> observable
> >> change outside modules (this change is being discussed on the -core 
> >> reflector
> >> currently).
> >>
> >> This also removes the prior special case for tag lookup, which made some 
> >> cases
> >> of this work, but also led to bizarre, bogus "must use 'struct' to refer 
> >> to type
> >> 'Foo' in this scope" diagnostics in C++.
> >
> > We’re seeing a build failure that seems like it is due to this change. The 
> > following code used to compile successfully:
> >
> > namespace llvm {
> > template  class AllocatorBase {};
> > namespace filter {
> > class Node {
> >  class NodeBits {};
> >  class UniformBits {};
> >  union {
> >UniformBits UniformBits;
> >  };
> >  static_assert(sizeof(UniformBits) <= 8, "fits in an uint64_6");
> > };
> > }
> > }
> >
> > but now we get "error: reference to 'UniformBits' is ambiguous” from the 
> > static_assert. It looks to me like this really is ambiguous and that the 
> > code should be changed. Can you confirm that?
> 
> [class.union] §9.5.5 states that "The names of the members of an anonymous 
> union shall be distinct from the names of any other entity in the scope in 
> which the anonymous union is declared.”
> 
> I read that as a confirmation that this is indeed illegal.
> 
> Yes, but we're diagnosing it the wrong way -- it's ill-formed even before the 
> ambiguous lookup that we now diagnose.

I filed https://llvm.org/bugs/show_bug.cgi?id=26048 
.

thanks,
adrian

>  
> -- adrian
> 
> >
> > I also noticed that we get a duplicated diagnostic in this case. I noticed 
> > that you fixed a related case in r252967, but it seems to be missing this 
> > case.
> >
> >>
> >> Added:
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/decls.h
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/empty.h
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap
> >>   cfe/trunk/test/Modules/no-linkage.cpp
> >> Modified:
> >>   cfe/trunk/include/clang/Sema/Lookup.h
> >>   cfe/trunk/lib/AST/Decl.cpp
> >>   cfe/trunk/lib/Sema/SemaDecl.cpp
> >>   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> >>   cfe/trunk/test/Index/linkage.c
> >>   cfe/trunk/test/Index/usrs.m
> >>   cfe/trunk/test/Modules/decldef.m
> >>   cfe/trunk/test/Modules/merge-enumerators.cpp
> >>   cfe/trunk/test/Modules/module-private.cpp
> >>   cfe/trunk/test/Modules/submodule-visibility-cycles.cpp
> >>   cfe/trunk/test/Modules/submodules-merge-defs.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Sema/Lookup.h
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=252960&r1=252959&r2=252960&view=diff
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
> >> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Nov 12 16:19:45 2015
> >> @@ -139,8 +139,7 @@ public:
> >>  Redecl(Redecl != Sema::NotForRedeclaration),
> >>  HideTags(true),
> >>  Diagnose(Redecl == Sema::NotForRedeclaration),
> >> -  AllowHidden(Redecl == Sema::ForRedeclaration),
> >> -  AllowHiddenInternal(AllowHidden),
> >> +  AllowHidden(false),
>

Re: [PATCH] D15448: [analyzer] SVal Visitor.

2016-01-06 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def:31
@@ +30,3 @@
+// is both instantiated and derived from.
+// Additionally, its kind is not its name with "Kind" suffix,
+// unlike all other regions.

NoQ wrote:
> zaks.anna wrote:
> > I'd rather rename the "Kind" suffix. Is that possible?
> > 
> > Having REGION and NORMAL_REGION is strange.
> In fact, `MemSpaceRegion` is quite special, because it is the only thing in 
> the hierarchy that can be both derived from (normally such values are marked 
> as "abstract") and instantiated (for which it has a kind defined). Instances 
> of MemSpaceRegion are used, at least, for holding some code regions. Probably 
> create a new memspace for such regions and remove the kind value?
> 
> Ok, i'd go ahead and prepare a separate review for unifying the naming 
> convention :)
Please, do if you agree that it makes sense.

Otherwise, this patch LGTM.


http://reviews.llvm.org/D15448



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


Re: [PATCH] D15611: [Patch 2/3]: Rebasing Ryan Govostes' STP patch for Clang SA

2016-01-06 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

What was the last outstanding issue with this patch (I believe it was related 
to either make or cmake changes)? 
Has it been addressed?


Repository:
  rL LLVM

http://reviews.llvm.org/D15611



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


r256967 - [WebAssembly] Add --gc-sections to the link line.

2016-01-06 Thread Dan Gohman via cfe-commits
Author: djg
Date: Wed Jan  6 13:43:32 2016
New Revision: 256967

URL: http://llvm.org/viewvc/llvm-project?rev=256967&view=rev
Log:
[WebAssembly] Add --gc-sections to the link line.

This will eventually be accompanied with a change to enable -ffunction-sections
and -fdata-sections by default, which is currently delayed by some development
process issues.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256967&r1=256966&r2=256967&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 13:43:32 2016
@@ -6534,6 +6534,11 @@ void wasm::Linker::ConstructJob(Compilat
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
+
+  // Enable garbage collection of unused input sections by default, since code
+  // size is of particular importance.
+  CmdArgs.push_back("--gc-sections");
+
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=256967&r1=256966&r2=256967&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan  6 13:43:32 2016
@@ -1,3 +1,3 @@
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown -x 
assembler %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}}" "-cc1as" {{.*}} "-o" "[[temp:[^"]*]]"
-// AS_LINK: lld{{.*}}" "-flavor" "ld" "[[temp]]" "-o" "a.out"
+// AS_LINK: lld{{.*}}" "-flavor" "ld" "--gc-sections" "[[temp]]" "-o" "a.out"


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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4283
@@ +4282,3 @@
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(notMatchesC("void f();", functionProtoType()));

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > > I don't understand what would be tested by adding a test for 
> > > parameterCountIs() on a function that doesn't have a prototype since it 
> > > is a nested matcher passed to functionProtoType() and since the function 
> > > doesn't have a prototype, that outer matcher won't match.
> > 
> > Not according to the AST matcher that was implemented -- it supports 
> > FunctionProtoType and FunctionDecl. I want to make sure that if you get to 
> > parameterCountIs() through functionDecl() that it doesn't fail.
> Ah, OK, you were asking for a test on `functionDecl`, not 
> `functionProtoType`.  I can do that.  I guess what threw me off is that the 
> comment was attached to the prototype tests.
Ah, yeah, one of the downsides to Phab sometimes is finding a good place to put 
comments for things that are missing. :-P Sorry for the confusion!


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4992
@@ +4991,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > > I'm happy to make the improvement, but I don't know how. I simply call 
> > > the Node.underlyingType(), just like hasType calls Node.getType(). I 
> > > don't know why they are different.
> > 
> > hasType() and hasUnderlyingType() have different operational semantic 
> > implications, at least to me. hasType() asks, "ultimately, what is the type 
> > of this thing?", and Node.underlyingType() answers that. To me, 
> > hasUnderlyingType() asks, "in the chain of types that this typedef refers 
> > to, does this thing match any of them?", and Node.underlyingType() does not 
> > answer that -- it only looks at the final desugared type. The difference we 
> > want is that hasType() continues to look at the final type, but 
> > hasUnderlyingType() needs to do more work to look at intermediary types and 
> > terminate that loop when the answer is "yes, it has this type" or "no, we 
> > can't desugar any further."
> > 
> > If we don't care about the intermediate types for your needs, then I don't 
> > see the point to hasUnderlyingType() being an AST matcher at all. hasType() 
> > does exactly what is needed, and you can instead modify that to accept a 
> > TypedefDecl in addition to Expr and ValueDecl. However, I still see value 
> > in hasUnderlyingType() because typedef chains can be long and complex (like 
> > in the Win32 APIs), and being able to query for intermediary types would be 
> > useful. e.g., I want to know about all types that have an intermediary type 
> > of DWORD (which itself is a typedef for an unsigned integer type). 
> > hasType() will always go to the final type, making such a matcher 
> > impossible without something like hasUnderlyingType().
> I just named the matcher after the 
> [accessor](http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html#a5fccedff6d3854db365a540145029158)
>  on a typedefDecl node.  To me it's just a narrowing matcher on that node 
> that gives you access to whatever the accessor returns.
> 
> Things may have changed in the meantime, but when I originally created this 
> patch you couldn't do `typedefDecl(hasType(asString("int")))`.  It doesn't 
> compile.  Since `hasType` just matched against the value of whatever 
> `Node.getType()` returned it seemed natural to add a matcher called 
> `hasUnderlyingType` that just matched against the value of whatever 
> `Node.getUnderlyingType()` returned.
> 
> As I said, I'm happy to make the suggested improvement, but beyond simple 
> immitation of existing matchers, I have no idea how to traverse the encodings 
> of types within the guts of clang.  This is what I mean when I say "I don't 
> know how".  I understand conceptually what you are saying but I have no idea 
> how to express that in clang's code base.
That's why I am trying to understand what your goal is. As best I can tell, 
there are two distinct things someone may want to do with a typedef's type: 
figure out what it ultimately boils down to, or traverse the typedef chain. I 
was uncertain which one fit your needs better, but it sounds like "get the 
ultimate type" is what you want. From there we can discuss what the proper 
design of the matcher is. I think I was thrown off by you naming it 
*has*UnderlyingType instead of *get*UnderlyingType because *has* implies a 
different relationship than *get* and I couldn't see why you wouldn't just 
update hasType() instead.

Another thing to th

Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Jason Henline via cfe-commits
jhen updated this revision to Diff 44143.
jhen added a comment.

- Assert setConfig only called once


http://reviews.llvm.org/D15858

Files:
  include/clang/AST/ExprCXX.h
  test/SemaCUDA/kernel-call.cu

Index: test/SemaCUDA/kernel-call.cu
===
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
 
   int (*fp)(int) = h2;
   fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -155,6 +155,7 @@
 class CUDAKernelCallExpr : public CallExpr {
 private:
   enum { CONFIG, END_PREARG };
+  bool IsConfigSet = false;
 
 public:
   CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config,
@@ -171,7 +172,19 @@
 return cast_or_null(getPreArg(CONFIG));
   }
   CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
-  void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
+
+  /// \brief Sets the kernel configuration expression.
+  ///
+  /// Note that this method can only be called once per class instance.
+  void setConfig(CallExpr *E) {
+assert(
+!IsConfigSet &&
+"CUDAKernelCallExpr.setConfig can only be called once per instance.");
+setPreArg(CONFIG, E);
+setInstantiationDependent(isInstantiationDependent() ||
+  E->isInstantiationDependent());
+IsConfigSet = true;
+  }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CUDAKernelCallExprClass;


Index: test/SemaCUDA/kernel-call.cu
===
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
 
   int (*fp)(int) = h2;
   fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
 }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -155,6 +155,7 @@
 class CUDAKernelCallExpr : public CallExpr {
 private:
   enum { CONFIG, END_PREARG };
+  bool IsConfigSet = false;
 
 public:
   CUDAKernelCallExpr(ASTContext &C, Expr *fn, CallExpr *Config,
@@ -171,7 +172,19 @@
 return cast_or_null(getPreArg(CONFIG));
   }
   CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
-  void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
+
+  /// \brief Sets the kernel configuration expression.
+  ///
+  /// Note that this method can only be called once per class instance.
+  void setConfig(CallExpr *E) {
+assert(
+!IsConfigSet &&
+"CUDAKernelCallExpr.setConfig can only be called once per instance.");
+setPreArg(CONFIG, E);
+setInstantiationDependent(isInstantiationDependent() ||
+  E->isInstantiationDependent());
+IsConfigSet = true;
+  }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CUDAKernelCallExprClass;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Jason Henline via cfe-commits
jhen marked an inline comment as done.


Comment at: test/SemaCUDA/kernel-call.cu:27
@@ -26,1 +26,3 @@
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }

rsmith wrote:
> jhen wrote:
> > Thanks for bringing this up. While trying to find tests that dealt with 
> > each dependence individually, I came to realize that value and type 
> > dependence should not be set for the CUDAKernelCallExpr node because it's 
> > value is always void. So, I removed the propagation of those two 
> > dependencies.
> > 
> > Then, while looking for a test that could handle the parameter pack 
> > information, I realized that it was opening up a whole new can of worms and 
> > that the triple-angle-bracket syntax does not currently support variadic 
> > templates. I decided that parameter packs should be handled as a separate 
> > bug, so I removed them from this patch.
> > 
> > The instantiation dependence propagation is still valid, though, because it 
> > just represents whether a template parameter is present anywhere in the 
> > expression, so I left it in. Correctly tracking instantiation dependence in 
> > enough to fix the bug this patch was meant to fix, so I think it is the 
> > only change that should be made in this patch.
> What happens if an unexpanded pack is used within the kernel arguments of a 
> CUDA kernel call? Do we already reject that? Are there tests for that 
> somewhere?
There don't seem to be any tests currently that handle this case.

The case I had in mind for an unexpanded parameter pack was something like the 
following:

  __global__ void kernel() {}

  template  kernel_wrapper() {
kernel<<>>();
  }

This currently leads to a warning at the time of parsing that says the closing 
">>>" is not found. I believe the cause is that the argument list is parsed as 
a simple argument list, so it doesn't handle the ellipsis correctly. I 
experimented with using standard (non-simple) parsing for the argument list, 
but that led to failures in other unit tests where ">>" wasn't being warned 
correctly in C++98 mode. I'm planning to file a bug for this (at least to fix 
the warning if not to allow the construction) and deal with it in a later 
patch. Does that sound reasonable?


http://reviews.llvm.org/D15858



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


[PATCH] D15933: Rename -nocudalib to -nocudalibdevice.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

Per discussion in D15596.

http://reviews.llvm.org/D15933

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains.cpp
  test/Driver/cuda-detect.cu

Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -34,9 +34,9 @@
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
-// .. or if we explicitly passed -nocudalib
+// .. or if we explicitly passed -nocudalibdevice
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
-// RUN:   -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
+// RUN:   -nocudalibdevice --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
 // Verify that we don't add include paths, link with libdevice or
 // -include __clang_cuda_runtime_wrapper.h without valid CUDA installation.
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4200,7 +4200,7 @@
   Linux::addClangTargetOptions(DriverArgs, CC1Args);
   CC1Args.push_back("-fcuda-is-device");
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nocudalibdevice))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1632,7 +1632,8 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nocudalibdevice : Flag<["-"], "nocudalibdevice">,
+  HelpText<"Don't link in the CUDA libdevice bitcode 
(libdevice.compute_xx.yy.bc)">;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;


Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -34,9 +34,9 @@
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
-// .. or if we explicitly passed -nocudalib
+// .. or if we explicitly passed -nocudalibdevice
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
-// RUN:   -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
+// RUN:   -nocudalibdevice --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
 // Verify that we don't add include paths, link with libdevice or
 // -include __clang_cuda_runtime_wrapper.h without valid CUDA installation.
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4200,7 +4200,7 @@
   Linux::addClangTargetOptions(DriverArgs, CC1Args);
   CC1Args.push_back("-fcuda-is-device");
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nocudalibdevice))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1632,7 +1632,8 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nocudalibdevice : Flag<["-"], "nocudalibdevice">,
+  HelpText<"Don't link in the CUDA libdevice bitcode (libdevice.compute_xx.yy.bc)">;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44145.
jlebar added a dependency: D15933: Rename -nocudalib to -nocudalibdevice..
jlebar added a comment.

Now also pass -lcudart_static -lcuda -ldl -lrt -pthread for CUDA compiles.

Depends on http://reviews.llvm.org/D15933.


http://reviews.llvm.org/D15596

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/cuda-default-libs.cu

Index: test/Driver/cuda-default-libs.cu
===
--- /dev/null
+++ test/Driver/cuda-default-libs.cu
@@ -0,0 +1,56 @@
+// Checks that we add -L /path/to/cuda/lib{,64} and -lcudart_static -lcuda -ldl
+// -lrt -pthread as appropriate when compiling CUDA code.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_32
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_64
+//
+// CUDA-x86_32: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-x86_64: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_32-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_64-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-DAG: "-lcudart_static"
+// CUDA-DAG: "-lcuda"
+// CUDA-DAG: "-ldl"
+// CUDA-DAG: "-lrt"
+// CUDA-DAG: "-pthread"
+
+// Don't double-include -lfoo.
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA -ldl %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix DOUBLE-INCLUDE
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA -ldl %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix DOUBLE-INCLUDE
+//
+// DOUBLE-INCLUDE-NOT: "-ldl{{.*}}-ldl"
+// DOUBLE-INCLUDE-NOT: "-pthread{{.*}}-pthread"
+
+// If we can't find CUDA, don't include it in our library search path, and
+// don't include any additional libraries via -l.
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/no-cuda-there %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// Also don't add anything if we pass -nocudalib.
+// RUN: %clang -### -v --target=x86_64-unknown-linux -nocudalib \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// NOCUDA-NOT: "-L" "{{.*}}/no-cuda-there/{{.*}}"
+// NOCUDA-NOT: "-lcudart_static"
+// NOCUDA-NOT: "-lcuda"
+// NOCUDA-NOT: "-ldl"
+// NOCUDA-NOT: "-lrt"
+// NOCUDA-NOT: "-pthread"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -224,8 +224,16 @@
   }
 }
 
-static void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
-const ArgList &Args, ArgStringList &CmdArgs) {
+// Is the given action, or any of its inputs, a CUDA action?
+static bool isCudaAction(const Action* A) {
+  return isa(A) || isa(A) ||
+ std::any_of(A->getInputs().begin(), A->getInputs().end(),
+ isCudaAction);
+}
+
+static void AddLinkerInputs(const Compilation &C, const ToolChain &TC,
+const InputInfoList &Inputs, const ArgList &Args,
+ArgStringList &CmdArgs) {
   const Driver &D = TC.getDriver();
 
   // Add extra linker input arguments which are not treated as inputs
@@ -264,6 +272,10 @@
   //and only supported on native toolchains.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+  // Add -L/path/to/cuda/lib if any of our inputs are .cu files.
+  if (std::any_of(C.getActions().begin(), C.getActions().end(), isCudaAction))
+TC.AddCudaLinkerArgs(Args, CmdArgs);
 }
 
 /// \brief Determine whether Objective-C automated reference counting is
@@ -6409,7 +6421,7 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_u_Group});
 
-  AddLinkerInputs(HTC, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, HTC, Inputs, Args, CmdArgs);
 
   //
   // Libraries
@@ -6472,7 +6484,7 @@
   CmdArgs.push_back("old-gnu");
   CmdArgs.push_back("-target");
   CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_uniqu

Re: [PATCH] D15928: Add -Wfor-loop-analysis to -Wall.

2016-01-06 Thread Richard Trieu via cfe-commits
rtrieu accepted this revision.
rtrieu added a comment.
This revision is now accepted and ready to land.

LGTM

The most complex things these warnings use is an AST visitor, so the compile 
time impact should be minimal.


http://reviews.llvm.org/D15928



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


Re: [PATCH] D15928: Add -Wfor-loop-analysis to -Wall.

2016-01-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

LGTM as well, FWIW


http://reviews.llvm.org/D15928



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


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar marked an inline comment as done.
jlebar added a comment.

Done, please have another look.


http://reviews.llvm.org/D15596



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


Re: [PATCH] D15933: Rename -nocudalib to -nocudalibdevice.

2016-01-06 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D15933



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


r256975 - Add -Wfor-loop-analysis to -Wall.

2016-01-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Jan  6 14:55:00 2016
New Revision: 256975

URL: http://llvm.org/viewvc/llvm-project?rev=256975&view=rev
Log:
Add -Wfor-loop-analysis to -Wall.

This warning seems to have 0 false positives and some true positives in
practice, without a measurable compile time cost.  It should be in -Wall, and
possibly even become a default warning at some point.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=256975&r1=256974&r2=256975&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jan  6 14:55:00 2016
@@ -616,6 +616,7 @@ def Most : DiagGroup<"most", [
 CharSubscript,
 Comment,
 DeleteNonVirtualDtor,
+ForLoopAnalysis,
 Format,
 Implicit,
 InfiniteRecursion,


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


Re: [PATCH] D15928: Add -Wfor-loop-analysis to -Wall.

2016-01-06 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

r256975, thanks!


http://reviews.llvm.org/D15928



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


r256976 - Improve conditional checking during template instantiation.

2016-01-06 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan  6 15:11:18 2016
New Revision: 256976

URL: http://llvm.org/viewvc/llvm-project?rev=256976&view=rev
Log:
Improve conditional checking during template instantiation.

When the condition in an if statement, while statement, or for loop is created
during template instantiation, it calls MakeFullExpr with only the condition
expression.  However, when these conditions are created for non-templated
code in the Parser, an additional SourceLocation is passed to MakeFullExpr.
The impact of this was that non-dependent templated code could produce
diagnostics that the same code outside templates would not.  Adding the missing
SourceLocation makes diagnostics consistent between templated and non-templated
code.

Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/conversion.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=256976&r1=256975&r2=256976&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Jan  6 15:11:18 2016
@@ -6128,7 +6128,7 @@ TreeTransform::TransformIfStmt(
 }
   }
 
-  Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.get()));
+  Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.get(), 
S->getIfLoc()));
   if (!S->getConditionVariable() && S->getCond() && !FullCond.get())
 return StmtError();
 
@@ -6223,7 +6223,8 @@ TreeTransform::TransformWhileSt
 }
   }
 
-  Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.get()));
+  Sema::FullExprArg FullCond(
+  getSema().MakeFullExpr(Cond.get(), S->getWhileLoc()));
   if (!S->getConditionVariable() && S->getCond() && !FullCond.get())
 return StmtError();
 
@@ -6307,7 +6308,8 @@ TreeTransform::TransformForStmt
 }
   }
 
-  Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.get()));
+  Sema::FullExprArg FullCond(
+  getSema().MakeFullExpr(Cond.get(), S->getForLoc()));
   if (!S->getConditionVariable() && S->getCond() && !FullCond.get())
 return StmtError();
 

Modified: cfe/trunk/test/SemaCXX/conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion.cpp?rev=256976&r1=256975&r2=256976&view=diff
==
--- cfe/trunk/test/SemaCXX/conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion.cpp Wed Jan  6 15:11:18 2016
@@ -77,30 +77,8 @@ void test3() {
   // CHECK: note: expanded from macro 'FINIT'
 #define FINIT int a3 = NULL;
   FINIT // expected-warning {{implicit conversion of NULL constant to 'int'}}
-
-  // we don't catch the case of #define FOO NULL ... int i = FOO; but that 
seems a bit narrow anyway
-  // and avoiding that helps us skip these cases:
-#define NULL_COND(cond) ((cond) ? &a : NULL)
-  bool bl2 = NULL_COND(true); // don't warn on NULL conversion through the 
conditional operator across a macro boundary
-  if (NULL_COND(true))
-;
-  while (NULL_COND(true))
-;
-  for (; NULL_COND(true); )
-;
-  do ;
-  while(NULL_COND(true));
-
-#define NULL_WRAPPER NULL_COND(false)
-  if (NULL_WRAPPER)
-;
-  while (NULL_WRAPPER)
-;
-  for (; NULL_WRAPPER;)
-;
-  do
-;
-  while (NULL_WRAPPER);
+  // we don't catch the case of #define FOO NULL ... int i = FOO; but that
+  // seems a bit narrow anyway and avoiding that helps us skip other cases.
 
   int *ip = NULL;
   int (*fp)() = NULL;
@@ -157,3 +135,66 @@ namespace test7 {
 return nullptr; // expected-warning {{implicit conversion of nullptr 
constant to 'bool'}}
   }
 }
+
+namespace test8 {
+  #define NULL_COND(cond) ((cond) ? &num : NULL)
+  #define NULL_WRAPPER NULL_COND(false)
+
+  // don't warn on NULL conversion through the conditional operator across a
+  // macro boundary
+  void macro() {
+int num;
+bool b = NULL_COND(true);
+if (NULL_COND(true)) {}
+while (NULL_COND(true)) {}
+for (;NULL_COND(true);) {}
+do {} while (NULL_COND(true));
+
+if (NULL_WRAPPER) {}
+while (NULL_WRAPPER) {}
+for (;NULL_WRAPPER;) {}
+do {} while (NULL_WRAPPER);
+  }
+
+  // Identical to the previous function except with a template argument.
+  // This ensures that template instantiation does not introduce any new
+  // warnings.
+  template 
+  void template_and_macro() {
+int num;
+bool b = NULL_COND(true);
+if (NULL_COND(true)) {}
+while (NULL_COND(true)) {}
+for (;NULL_COND(true);) {}
+do {} while (NULL_COND(true));
+
+if (NULL_WRAPPER) {}
+while (NULL_WRAPPER) {}
+for (;NULL_WRAPPER;) {}
+do {} while (NULL_WRAPPER);
+  }
+
+  // Identical to the previous function except the template argument affects
+  // the conditional statement.
+  template 
+  void template_and_macro2() {
+X num;
+bool b = NULL_COND(true);
+if (NULL_COND(true)) {}
+while (NULL_COND(true)) {}
+for (;NULL_COND(

r256977 - [Hexagon] Treat -march and -mcpu as equivalent

2016-01-06 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Jan  6 15:12:03 2016
New Revision: 256977

URL: http://llvm.org/viewvc/llvm-project?rev=256977&view=rev
Log:
[Hexagon] Treat -march and -mcpu as equivalent

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=256977&r1=256976&r2=256977&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Jan  6 15:12:03 2016
@@ -2716,13 +2716,8 @@ const StringRef HexagonToolChain::GetDef
 
 const StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
   Arg *CpuArg = nullptr;
-
-  for (auto &A : Args) {
-if (A->getOption().matches(options::OPT_mcpu_EQ)) {
-  CpuArg = A;
-  A->claim();
-}
-  }
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ, options::OPT_march_EQ))
+CpuArg = A;
 
   StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
   if (CPU.startswith("hexagon"))


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


[PATCH] D15935: Improve diagnostics for literal conversion to Boolean

2016-01-06 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie.
aaron.ballman added a subscriber: cfe-commits.

This patch improves the literal conversion diagnostics where the target type is 
a Boolean by handling literals more consistently, and telling the user whether 
the resulting value will be true or false.

This patch changes the behavior of literal conversions from floating-point 
literals in two ways: (1) we now always diagnose instead of silently accepting 
conversions where the float can be converted to an exact integer value, and (2) 
we drop the information about what the source value of the floating-point 
literal is (it's unimportant information in the context of the Boolean 
conversion).

This patch removes the string literal conversion diagnostic (and 
-Wstring-conversion) which is off by default, and rolls its functionality into 
-Wliteral-conversion, which is on by default. Since we already handle string 
literal to bool conversion through logical && to not diagnose, I do not believe 
this will increase the chattiness of the diagnostic. In fact, turning the 
diagnostic to on by default caught a few tests that were accidentally using 
string->bool literal conversions. This does change the wording of the previous 
diagnostic, but I think the new wording is an improvement.

This patch now diagnoses character literal conversions to Boolean types where 
they used to be silently accepted.

http://reviews.llvm.org/D15935

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Analysis/casts.c
  test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
  test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
  test/Sema/exprs.c
  test/Sema/warn-string-conversion.c
  test/SemaCXX/condition.cpp
  test/SemaCXX/overload-call.cpp
  test/SemaCXX/warn-literal-conversion.cpp
  test/SemaCXX/warn-string-conversion.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1046,8 +1046,8 @@
   struct Bas { void operator& (Foo &) {} };
   void mumble()
   {
-Bas() & Bar().func() << "" << "";
-Bas() & Bar().func() << "";
+Bas() & Bar().func() << true << true;
+Bas() & Bar().func() << true;
   }
 } // end namespace thread_annot_lock_61_modified
 
Index: test/SemaCXX/warn-string-conversion.cpp
===
--- test/SemaCXX/warn-string-conversion.cpp
+++ test/SemaCXX/warn-string-conversion.cpp
@@ -1,24 +1,24 @@
-// RUN: %clang_cc1 -fsyntax-only -Wstring-conversion -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 // Warn on cases where a string literal is converted into a bool.
 // An exception is made for this in logical and operators.
 void assert(bool condition);
 void test0() {
-  bool b0 = "hi"; // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
-  b0 = ""; // expected-warning{{implicit conversion turns string literal into bool: 'const char [1]' to 'bool'}}
-  b0 = 0 || ""; // expected-warning{{implicit conversion turns string literal into bool: 'const char [1]' to 'bool'}}
-  b0 = "" || 0; // expected-warning{{implicit conversion turns string literal into bool: 'const char [1]' to 'bool'}}
+  bool b0 = "hi"; // expected-warning{{implicit conversion from 'const char [3]' to 'bool'; will always evaluate to 'true'}}
+  b0 = ""; // expected-warning{{implicit conversion from 'const char [1]' to 'bool'; will always evaluate to 'true'}}
+  b0 = 0 || ""; // expected-warning{{implicit conversion from 'const char [1]' to 'bool'; will always evaluate to 'true'}}
+  b0 = "" || 0; // expected-warning{{implicit conversion from 'const char [1]' to 'bool'; will always evaluate to 'true'}}
   b0 = 0 && "";
   b0 = "" && 0;
-  assert("error"); // expected-warning{{implicit conversion turns string literal into bool: 'const char [6]' to 'bool'}}
-  assert(0 || "error"); // expected-warning{{implicit conversion turns string literal into bool: 'const char [6]' to 'bool'}}
-  assert("error" || 0); // expected-warning{{implicit conversion turns string literal into bool: 'const char [6]' to 'bool'}}
+  assert("error"); // expected-warning{{implicit conversion from 'const char [6]' to 'bool'; will always evaluate to 'true'}}
+  assert(0 || "error"); // expected-warning{{implicit conversion from 'const char [6]' to 'bool'; will always evaluate to 'true'}}
+  assert("error" || 0); // expected-warning{{implicit conversion from 'const char [6]' to 'bool'; will always evaluate to 'true'}}
   assert(0 && "error");
   assert("error" && 0);
 
-  while("hi") {} // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
-  do {} while("hi"); // expected-warning{{implicit conversi

[PATCH] D15936: Update code in buildCudaActions to latest idiom.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

Use llvm::make_unique, std::all_of, std::find, etc.

No functional changes.

Prerequisite for further changes to Driver.

http://reviews.llvm.org/D15936

Files:
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1291,18 +1291,19 @@
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
-return std::unique_ptr(
-new CudaHostAction(std::move(HostAction), {}));
+return llvm::make_unique(std::move(HostAction),
+ ActionList());
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
+  continue;
 }
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported 
GPUs.
@@ -1325,13 +1326,9 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate 
PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation = std::any_of(
+  CudaDeviceActions.begin(), CudaDeviceActions.end(),
+  [](const Action *a) { return a->getKind() != Action::BackendJobClass; });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1355,7 +1352,7 @@
   /* AtTopLevel */ true));
 // Kill host action in case of device-only compilation.
 if (DeviceOnlyCompilation)
-  HostAction.reset(nullptr);
+  HostAction.reset();
 return HostAction;
   }
 
@@ -1368,8 +1365,8 @@
 /* AtTopLevel */ false));
   // Return a new host action that incorporates original host action and all
   // device actions.
-  return std::unique_ptr(
-  new CudaHostAction(std::move(HostAction), DeviceActions));
+  return llvm::make_unique(std::move(HostAction),
+   DeviceActions);
 }
 
 void Driver::BuildActions(Compilation &C, const ToolChain &TC,
@@ -1470,12 +1467,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto &Phase : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ std::find(PL.begin(), PL.end(), phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::unique_ptr Current(new InputAction(*InputArg, InputType));


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1291,18 +1291,19 @@
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
-return std::unique_ptr(
-new CudaHostAction(std::move(HostAction), {}));
+return llvm::make_unique(std::move(HostAction),
+ ActionList());
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
+  continue;
 }
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported GPUs.
@@ -1325,13 +1326,9 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation = std::any_of(
+  

r256978 - [Hexagon] Expand -mvN to -mcpu=hexagonvN

2016-01-06 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Jan  6 15:27:42 2016
New Revision: 256978

URL: http://llvm.org/viewvc/llvm-project?rev=256978&view=rev
Log:
[Hexagon] Expand -mvN to -mcpu=hexagonvN

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=256978&r1=256977&r2=256978&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jan  6 15:27:42 2016
@@ -1906,13 +1906,13 @@ def _ : Joined<["--"], "">, Flags<[Unsup
 
 def mieee_rnd_near : Flag<["-"], "mieee-rnd-near">, 
Group;
 def mv4 : Flag<["-"], "mv4">, Group,
-  Alias, AliasArgs<["v4"]>;
+  Alias, AliasArgs<["hexagonv4"]>;
 def mv5 : Flag<["-"], "mv5">, Group, Alias,
-  AliasArgs<["v5"]>;
+  AliasArgs<["hexagonv5"]>;
 def mv55 : Flag<["-"], "mv55">, Group,
-   Alias, AliasArgs<["v55"]>;
+   Alias, AliasArgs<["hexagonv55"]>;
 def mv60 : Flag<["-"], "mv60">, Group,
-   Alias, AliasArgs<["v60"]>;
+   Alias, AliasArgs<["hexagonv60"]>;
 def mhexagon_hvx : Flag<["-"], "mhvx">, Group,
 Flags<[CC1Option]>, HelpText<"Enable Hexagon Vector eXtensions">;
 def mno_hexagon_hvx : Flag<["-"], "mno-hvx">, Group,


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


Re: [PATCH] D15936: Update code in buildCudaActions and BuildActions to latest idiom.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44154.
jlebar added a dependency: D15911: Switch Action and ActionList over to using 
std::shared_ptr..
jlebar added a comment.

Rebasing onto http://reviews.llvm.org/D15911.

Depends on http://reviews.llvm.org/D15911.


http://reviews.llvm.org/D15936

Files:
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,11 +1297,12 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
+  continue;
 }
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported 
GPUs.
@@ -1324,13 +1325,9 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate 
PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation = std::any_of(
+  CudaDeviceActions.begin(), CudaDeviceActions.end(),
+  [](const Action *a) { return a->getKind() != Action::BackendJobClass; });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1468,12 +1465,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto &Phase : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ std::find(PL.begin(), PL.end(), phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::shared_ptr Current =


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,11 +1297,12 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
+  continue;
 }
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported GPUs.
@@ -1324,13 +1325,9 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation = std::any_of(
+  CudaDeviceActions.begin(), CudaDeviceActions.end(),
+  [](const Action *a) { return a->getKind() != Action::BackendJobClass; });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1468,12 +1465,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto &Phase : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ std::find(PL.begin(), PL.end(), phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::shared_ptr Current =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15936: Update code in buildCudaActions and BuildActions to latest idiom.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44155.
jlebar added a comment.

Fix rebase conflict.


http://reviews.llvm.org/D15936

Files:
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,11 +1297,12 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
+  continue;
 }
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported 
GPUs.
@@ -1324,13 +1325,11 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate 
PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation =
+  std::any_of(CudaDeviceActions.begin(), CudaDeviceActions.end(),
+  [](const std::shared_ptr a) {
+return a->getKind() != Action::BackendJobClass;
+  });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1468,12 +1467,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto &Phase : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ std::find(PL.begin(), PL.end(), phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::shared_ptr Current =


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,11 +1297,12 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
+  continue;
 }
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported GPUs.
@@ -1324,13 +1325,11 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation =
+  std::any_of(CudaDeviceActions.begin(), CudaDeviceActions.end(),
+  [](const std::shared_ptr a) {
+return a->getKind() != Action::BackendJobClass;
+  });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1468,12 +1467,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto &Phase : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ std::find(PL.begin(), PL.end(), phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::shared_ptr Current =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: include/clang/Driver/Options.td:1636
@@ -1635,1 +1635,3 @@
+def nocudalib : Flag<["-"], "nocudalib">,
+  HelpText<"Don't include libraries necessary for running CUDA 
(-L/path/to/cuda/lib{,64} -lcudart_static -lrt -lpthread -ldl)">;
 def nocudalibdevice : Flag<["-"], "nocudalibdevice">,

include -> link with

Perhaps less implementation details would be more appropriate for a help string.
"Don't link with default CUDA runtime library"?


Comment at: lib/Driver/ToolChains.cpp:4129-4137
@@ +4128,11 @@
+  LDArgs.push_back("-L");
+  LDArgs.push_back(DriverArgs.MakeArgString(CudaInstallation.getLibPath()));
+  auto AddIfNotPresent = [&](const char *Flag) {
+llvm::StringRef FlagRef(Flag);
+if (std::find_if(LDArgs.begin(), LDArgs.end(), [FlagRef](const char *A) {
+  return llvm::StringRef(A) == FlagRef;
+}) == LDArgs.end()) {
+  LDArgs.push_back(DriverArgs.MakeArgString(Flag));
+}
+  };
+  AddIfNotPresent("-lcudart_static");

Does this kick in before user's arguments have been added or after?
If user args have not been added yet, then you'll never find them and don't 
need this check at all.

Skipping -lFOO will also have problems if any of the libraries are static and 
one of preceding libraries needs extra symbols that were not linked in by this 
point yet.

Link with required libraries unconditionally. Make sure to add these libraries 
after user arguments have been added.



Comment at: lib/Driver/ToolChains.cpp:4139
@@ +4138,3 @@
+  AddIfNotPresent("-lcudart_static");
+  AddIfNotPresent("-lcuda");
+  AddIfNotPresent("-ldl");

-lcuda is not needed. As far as I can tell, cudart_static will open and use it 
via dlopen.

It would be needed only if user uses any of API calls from libcuda directly, 
but then it would be up to user to add -lcuda.


Comment at: lib/Driver/ToolChains.cpp:4142
@@ +4141,3 @@
+  AddIfNotPresent("-lrt");
+  AddIfNotPresent("-pthread");
+}

-lpthread


http://reviews.llvm.org/D15596



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


r256979 - Fix half of PR26048. We don't yet diagnose the case where the anonymous union member is declared first and the tag name is declared second.

2016-01-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  6 15:54:29 2016
New Revision: 256979

URL: http://llvm.org/viewvc/llvm-project?rev=256979&view=rev
Log:
Fix half of PR26048. We don't yet diagnose the case where the anonymous union 
member is declared first and the tag name is declared second.

Added:
cfe/trunk/test/CXX/class/class.union/class.union.anon/
cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp
cfe/trunk/test/CXX/class/class.union/class.union.anon/p4.cpp
  - copied unchanged from r256599, 
cfe/trunk/test/CXX/class/class.union/p8.cpp
Removed:
cfe/trunk/test/CXX/class/class.union/p8.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/class/class.mem/p13.cpp
cfe/trunk/test/SemaCXX/anonymous-union.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256979&r1=256978&r2=256979&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan  6 15:54:29 2016
@@ -3962,9 +3962,6 @@ static bool CheckAnonMemberRedeclaration
  Sema::ForRedeclaration);
   if (!SemaRef.LookupName(R, S)) return false;
 
-  if (R.getAsSingle())
-return false;
-
   // Pick a representative declaration.
   NamedDecl *PrevDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
   assert(PrevDecl && "Expected a non-null Decl");
@@ -4675,11 +4672,13 @@ bool Sema::DiagnoseClassNameShadow(DeclC
DeclarationNameInfo NameInfo) {
   DeclarationName Name = NameInfo.getName();
 
-  if (CXXRecordDecl *Record = dyn_cast(DC)) 
-if (Record->getIdentifier() && Record->getDeclName() == Name) {
-  Diag(NameInfo.getLoc(), diag::err_member_name_of_class) << Name;
-  return true;
-}
+  CXXRecordDecl *Record = dyn_cast(DC);
+  while (Record && Record->isAnonymousStructOrUnion())
+Record = dyn_cast(Record->getParent());
+  if (Record && Record->getIdentifier() && Record->getDeclName() == Name) {
+Diag(NameInfo.getLoc(), diag::err_member_name_of_class) << Name;
+return true;
+  }
 
   return false;
 }

Modified: cfe/trunk/test/CXX/class/class.mem/p13.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.mem/p13.cpp?rev=256979&r1=256978&r2=256979&view=diff
==
--- cfe/trunk/test/CXX/class/class.mem/p13.cpp (original)
+++ cfe/trunk/test/CXX/class/class.mem/p13.cpp Wed Jan  6 15:54:29 2016
@@ -58,12 +58,12 @@ struct X3a {
 };
 
 // - every member of every anonymous union that is a member of class T.
-struct X4 {
+struct X4 { // expected-note{{previous}}
   union {
 int X;
 union {
   float Y;
-  unsigned X4; // expected-error{{member 'X4' has the same name as its 
class}}
+  unsigned X4; // expected-error{{redeclares 'X4'}}
 };
   };
 };

Added: cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp?rev=256979&view=auto
==
--- cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp (added)
+++ cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp Wed Jan  6 
15:54:29 2016
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -verify %s
+
+struct X {
+  int a; // expected-note {{previous}}
+  void b(); // expected-note {{previous}}
+  struct c; // expected-note {{previous}}
+  typedef int d; // expected-note {{previous}}
+
+  union {
+int a; // expected-error {{member of anonymous union redeclares}}
+int b; // expected-error {{member of anonymous union redeclares}}
+int c; // expected-error {{member of anonymous union redeclares}}
+int d; // expected-error {{member of anonymous union redeclares}}
+int e; // expected-note {{previous}}
+int f; // expected-note {{previous}}
+int g;
+int h; // expected-note {{previous}}
+  };
+
+  int e; // expected-error {{duplicate member}}
+  void f(); // expected-error {{redefinition}}
+  // FIXME: This is ill-formed, even though one name is a tag and the other is
+  // an anonymous union member. Reject this.
+  struct g;
+  typedef int h; // expected-error {{redefinition}}
+};

Removed: cfe/trunk/test/CXX/class/class.union/p8.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.union/p8.cpp?rev=256978&view=auto
==
--- cfe/trunk/test/CXX/class/class.union/p8.cpp (original)
+++ cfe/trunk/test/CXX/class/class.union/p8.cpp (removed)
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -verify %s
-
-union U {
-  int x = 0; // expected-note {{previous initialization is here}}
-  union {};
-  union {
-int z;
-int y = 1; // expected-error {{initializing multiple members of union}}
-  };
-};

Modified: 

Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44156.
jlebar marked 4 inline comments as done.
jlebar added a comment.

Address tra's review comments.


http://reviews.llvm.org/D15596

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/cuda-default-libs.cu

Index: test/Driver/cuda-default-libs.cu
===
--- /dev/null
+++ test/Driver/cuda-default-libs.cu
@@ -0,0 +1,40 @@
+// Checks that we add -L /path/to/cuda/lib{,64} and -lcudart_static -ldl -lrt
+// -lpthread as appropriate when compiling CUDA code.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_32
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_64
+//
+// CUDA-x86_32: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-x86_64: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_32-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_64-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-DAG: "-lcudart_static"
+// CUDA-DAG: "-ldl"
+// CUDA-DAG: "-lrt"
+// CUDA-DAG: "-lpthread"
+
+// If we can't find CUDA, don't include it in our library search path, and
+// don't include any additional libraries via -l.
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/no-cuda-there %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// Also don't add anything if we pass -nocudalib.
+// RUN: %clang -### -v --target=x86_64-unknown-linux -nocudalib \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// NOCUDA-NOT: "-L" "{{.*}}/no-cuda-there/{{.*}}"
+// NOCUDA-NOT: "-lcudart_static"
+// NOCUDA-NOT: "-ldl"
+// NOCUDA-NOT: "-lrt"
+// NOCUDA-NOT: "-lpthread"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -224,8 +224,16 @@
   }
 }
 
-static void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
-const ArgList &Args, ArgStringList &CmdArgs) {
+// Is the given action, or any of its inputs, a CUDA action?
+static bool isCudaAction(const Action* A) {
+  return isa(A) || isa(A) ||
+ std::any_of(A->getInputs().begin(), A->getInputs().end(),
+ isCudaAction);
+}
+
+static void AddLinkerInputs(const Compilation &C, const ToolChain &TC,
+const InputInfoList &Inputs, const ArgList &Args,
+ArgStringList &CmdArgs) {
   const Driver &D = TC.getDriver();
 
   // Add extra linker input arguments which are not treated as inputs
@@ -264,6 +272,10 @@
   //and only supported on native toolchains.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+  // Add -L/path/to/cuda/lib if any of our inputs are .cu files.
+  if (std::any_of(C.getActions().begin(), C.getActions().end(), isCudaAction))
+TC.AddCudaLinkerArgs(Args, CmdArgs);
 }
 
 /// \brief Determine whether Objective-C automated reference counting is
@@ -6409,7 +6421,7 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_u_Group});
 
-  AddLinkerInputs(HTC, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, HTC, Inputs, Args, CmdArgs);
 
   //
   // Libraries
@@ -6472,7 +6484,7 @@
   CmdArgs.push_back("old-gnu");
   CmdArgs.push_back("-target");
   CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
@@ -6500,7 +6512,7 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Linker, CmdArgs, Inputs));
@@ -6803,7 +6815,7 @@
   if (D.isUsingLTO())
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
 
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, ToolChain, Inputs, Args

Re: r256979 - Fix half of PR26048. We don't yet diagnose the case where the anonymous union member is declared first and the tag name is declared second.

2016-01-06 Thread Adrian Prantl via cfe-commits

> On Jan 6, 2016, at 1:54 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Wed Jan  6 15:54:29 2016
> New Revision: 256979
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256979&view=rev
> Log:
> Fix half of PR26048. We don't yet diagnose the case where the anonymous union 
> member is declared first and the tag name is declared second.
> 

Thanks!

-- adrian

> Added:
>cfe/trunk/test/CXX/class/class.union/class.union.anon/
>cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp
>cfe/trunk/test/CXX/class/class.union/class.union.anon/p4.cpp
>  - copied unchanged from r256599, 
> cfe/trunk/test/CXX/class/class.union/p8.cpp
> Removed:
>cfe/trunk/test/CXX/class/class.union/p8.cpp
> Modified:
>cfe/trunk/lib/Sema/SemaDecl.cpp
>cfe/trunk/test/CXX/class/class.mem/p13.cpp
>cfe/trunk/test/SemaCXX/anonymous-union.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256979&r1=256978&r2=256979&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan  6 15:54:29 2016
> @@ -3962,9 +3962,6 @@ static bool CheckAnonMemberRedeclaration
>  Sema::ForRedeclaration);
>   if (!SemaRef.LookupName(R, S)) return false;
> 
> -  if (R.getAsSingle())
> -return false;
> -
>   // Pick a representative declaration.
>   NamedDecl *PrevDecl = R.getRepresentativeDecl()->getUnderlyingDecl();
>   assert(PrevDecl && "Expected a non-null Decl");
> @@ -4675,11 +4672,13 @@ bool Sema::DiagnoseClassNameShadow(DeclC
>DeclarationNameInfo NameInfo) {
>   DeclarationName Name = NameInfo.getName();
> 
> -  if (CXXRecordDecl *Record = dyn_cast(DC)) 
> -if (Record->getIdentifier() && Record->getDeclName() == Name) {
> -  Diag(NameInfo.getLoc(), diag::err_member_name_of_class) << Name;
> -  return true;
> -}
> +  CXXRecordDecl *Record = dyn_cast(DC);
> +  while (Record && Record->isAnonymousStructOrUnion())
> +Record = dyn_cast(Record->getParent());
> +  if (Record && Record->getIdentifier() && Record->getDeclName() == Name) {
> +Diag(NameInfo.getLoc(), diag::err_member_name_of_class) << Name;
> +return true;
> +  }
> 
>   return false;
> }
> 
> Modified: cfe/trunk/test/CXX/class/class.mem/p13.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.mem/p13.cpp?rev=256979&r1=256978&r2=256979&view=diff
> ==
> --- cfe/trunk/test/CXX/class/class.mem/p13.cpp (original)
> +++ cfe/trunk/test/CXX/class/class.mem/p13.cpp Wed Jan  6 15:54:29 2016
> @@ -58,12 +58,12 @@ struct X3a {
> };
> 
> // - every member of every anonymous union that is a member of class T.
> -struct X4 {
> +struct X4 { // expected-note{{previous}}
>   union {
> int X;
> union {
>   float Y;
> -  unsigned X4; // expected-error{{member 'X4' has the same name as its 
> class}}
> +  unsigned X4; // expected-error{{redeclares 'X4'}}
> };
>   };
> };
> 
> Added: cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp?rev=256979&view=auto
> ==
> --- cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp (added)
> +++ cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp Wed Jan  6 
> 15:54:29 2016
> @@ -0,0 +1,26 @@
> +// RUN: %clang_cc1 -verify %s
> +
> +struct X {
> +  int a; // expected-note {{previous}}
> +  void b(); // expected-note {{previous}}
> +  struct c; // expected-note {{previous}}
> +  typedef int d; // expected-note {{previous}}
> +
> +  union {
> +int a; // expected-error {{member of anonymous union redeclares}}
> +int b; // expected-error {{member of anonymous union redeclares}}
> +int c; // expected-error {{member of anonymous union redeclares}}
> +int d; // expected-error {{member of anonymous union redeclares}}
> +int e; // expected-note {{previous}}
> +int f; // expected-note {{previous}}
> +int g;
> +int h; // expected-note {{previous}}
> +  };
> +
> +  int e; // expected-error {{duplicate member}}
> +  void f(); // expected-error {{redefinition}}
> +  // FIXME: This is ill-formed, even though one name is a tag and the other 
> is
> +  // an anonymous union member. Reject this.
> +  struct g;
> +  typedef int h; // expected-error {{redefinition}}
> +};
> 
> Removed: cfe/trunk/test/CXX/class/class.union/p8.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.union/p8.cpp?rev=256978&view=auto
> ==
> --- cfe/trunk/test/CXX/class/class.union/p8.cpp (original)
> +++ cfe/trunk/test

Re: [PATCH] D15936: Update code in buildCudaActions and BuildActions to latest idiom.

2016-01-06 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: lib/Driver/Driver.cpp:1300
@@ -1299,5 +1299,3 @@
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
+  continue;

style nit -- no need for {}


http://reviews.llvm.org/D15936



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


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Updated code; please have a look.



Comment at: include/clang/Driver/Options.td:1636
@@ -1635,1 +1635,3 @@
+def nocudalib : Flag<["-"], "nocudalib">,
+  HelpText<"Don't include libraries necessary for running CUDA 
(-L/path/to/cuda/lib{,64} -lcudart_static -lrt -lpthread -ldl)">;
 def nocudalibdevice : Flag<["-"], "nocudalibdevice">,

tra wrote:
> include -> link with
> 
> Perhaps less implementation details would be more appropriate for a help 
> string.
> "Don't link with default CUDA runtime library"?
> include -> link with

Done.

> Perhaps less implementation details would be more appropriate for a help 
> string.

I'm not sure about that?  Maybe if we were just including -lcudart_static, but 
given that we're pulling in other libraries and adding a library search path, I 
feel like we should tell users what we're doing?  I mean, we should document it 
somewhere, and here's where people are actually going to find it...


Comment at: lib/Driver/ToolChains.cpp:4129-4137
@@ +4128,11 @@
+  LDArgs.push_back("-L");
+  LDArgs.push_back(DriverArgs.MakeArgString(CudaInstallation.getLibPath()));
+  auto AddIfNotPresent = [&](const char *Flag) {
+llvm::StringRef FlagRef(Flag);
+if (std::find_if(LDArgs.begin(), LDArgs.end(), [FlagRef](const char *A) {
+  return llvm::StringRef(A) == FlagRef;
+}) == LDArgs.end()) {
+  LDArgs.push_back(DriverArgs.MakeArgString(Flag));
+}
+  };
+  AddIfNotPresent("-lcudart_static");

tra wrote:
> Does this kick in before user's arguments have been added or after?
> If user args have not been added yet, then you'll never find them and don't 
> need this check at all.
> 
> Skipping -lFOO will also have problems if any of the libraries are static and 
> one of preceding libraries needs extra symbols that were not linked in by 
> this point yet.
> 
> Link with required libraries unconditionally. Make sure to add these 
> libraries after user arguments have been added.
> 
> Does this kick in before user's arguments have been added or after?

After; I wrote tests.  :)

> Link with required libraries unconditionally.

Done.


Comment at: lib/Driver/ToolChains.cpp:4142
@@ +4141,3 @@
+  AddIfNotPresent("-lrt");
+  AddIfNotPresent("-pthread");
+}

tra wrote:
> -lpthread
Oh, I see, -pthread is a compile-time flag, not a link-time flag.  Thanks.


http://reviews.llvm.org/D15596



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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/ExprCXX.h:181
@@ +180,3 @@
+assert(
+!IsConfigSet &&
+"CUDAKernelCallExpr.setConfig can only be called once per instance.");

Perhaps `assert(!getPreArg(CONFIG))` instead of storing a separate flag?


Comment at: test/SemaCUDA/kernel-call.cu:27
@@ -26,1 +26,3 @@
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }

Your approach for that testcase seems fine, but it's not a test for the right 
thing as it doesn't have an unexpanded pack within the kernel call args. Here's 
a testcase for that scenario:

  template void kernel_wrapper() {
void (*fs[])() = {
  []{ kernel<<>>(); } ...
};
  }


http://reviews.llvm.org/D15858



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


Re: [PATCH] D15936: Update code in buildCudaActions and BuildActions to latest idiom.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44158.
jlebar added a comment.

Address tra's review comments.


http://reviews.llvm.org/D15936

Files:
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,11 +1297,11 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
-}
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
+  continue;
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported 
GPUs.
@@ -1324,13 +1324,11 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate 
PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation =
+  std::any_of(CudaDeviceActions.begin(), CudaDeviceActions.end(),
+  [](const std::shared_ptr a) {
+return a->getKind() != Action::BackendJobClass;
+  });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1468,12 +1466,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto &Phase : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ std::find(PL.begin(), PL.end(), phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::shared_ptr Current =


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1297,11 +1297,11 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
-}
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
+  continue;
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported GPUs.
@@ -1324,13 +1324,11 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation =
+  std::any_of(CudaDeviceActions.begin(), CudaDeviceActions.end(),
+  [](const std::shared_ptr a) {
+return a->getKind() != Action::BackendJobClass;
+  });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1468,12 +1466,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto &Phase : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ std::find(PL.begin(), PL.end(), phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::shared_ptr Current =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15936: Update code in buildCudaActions and BuildActions to latest idiom.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar marked an inline comment as done.
jlebar added a comment.

http://reviews.llvm.org/D15936



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


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44160.
jlebar added a comment.

Adding back testcase that ensures that our flags are added after user flags.


http://reviews.llvm.org/D15596

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/cuda-default-libs.cu

Index: test/Driver/cuda-default-libs.cu
===
--- /dev/null
+++ test/Driver/cuda-default-libs.cu
@@ -0,0 +1,42 @@
+// Checks that we add -L /path/to/cuda/lib{,64} and -lcudart_static -ldl -lrt
+// -lpthread as appropriate when compiling CUDA code.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   -lfoo --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_32
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   -lfoo --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_64
+//
+// # Our new flags should come after user-specified flags.
+// CUDA: -lfoo
+// CUDA-x86_32: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-x86_64: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_32-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_64-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-DAG: "-lcudart_static"
+// CUDA-DAG: "-ldl"
+// CUDA-DAG: "-lrt"
+// CUDA-DAG: "-lpthread"
+
+// If we can't find CUDA, don't include it in our library search path, and
+// don't include any additional libraries via -l.
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/no-cuda-there %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// Also don't add anything if we pass -nocudalib.
+// RUN: %clang -### -v --target=x86_64-unknown-linux -nocudalib \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// NOCUDA-NOT: "-L" "{{.*}}/no-cuda-there/{{.*}}"
+// NOCUDA-NOT: "-lcudart_static"
+// NOCUDA-NOT: "-ldl"
+// NOCUDA-NOT: "-lrt"
+// NOCUDA-NOT: "-lpthread"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -224,8 +224,16 @@
   }
 }
 
-static void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
-const ArgList &Args, ArgStringList &CmdArgs) {
+// Is the given action, or any of its inputs, a CUDA action?
+static bool isCudaAction(const Action* A) {
+  return isa(A) || isa(A) ||
+ std::any_of(A->getInputs().begin(), A->getInputs().end(),
+ isCudaAction);
+}
+
+static void AddLinkerInputs(const Compilation &C, const ToolChain &TC,
+const InputInfoList &Inputs, const ArgList &Args,
+ArgStringList &CmdArgs) {
   const Driver &D = TC.getDriver();
 
   // Add extra linker input arguments which are not treated as inputs
@@ -264,6 +272,10 @@
   //and only supported on native toolchains.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+  // Add -L/path/to/cuda/lib if any of our inputs are .cu files.
+  if (std::any_of(C.getActions().begin(), C.getActions().end(), isCudaAction))
+TC.AddCudaLinkerArgs(Args, CmdArgs);
 }
 
 /// \brief Determine whether Objective-C automated reference counting is
@@ -6409,7 +6421,7 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_u_Group});
 
-  AddLinkerInputs(HTC, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, HTC, Inputs, Args, CmdArgs);
 
   //
   // Libraries
@@ -6472,7 +6484,7 @@
   CmdArgs.push_back("old-gnu");
   CmdArgs.push_back("-target");
   CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
@@ -6500,7 +6512,7 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Linker, CmdArgs, Inputs));
@@ -6803,7 +6815,7 @@
   if (D.isUsingLTO())
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
 
-  Add

Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Driver/ToolChains.cpp:4129-4137
@@ -4123,4 +4128,11 @@
+  LDArgs.push_back("-L");
+  LDArgs.push_back(DriverArgs.MakeArgString(CudaInstallation.getLibPath()));
+  for (const char *Flag : {"-lcudart_static", "-ldl", "-lrt", "-lpthread"}) {
+LDArgs.push_back(DriverArgs.MakeArgString(Flag));
+  }
+}
+
 bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;

Although then I deleted the relevant tests...  I just added new ones.  :)


http://reviews.llvm.org/D15596



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


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Minor nit, but looks good otherwise.



Comment at: include/clang/Driver/Options.td:1636
@@ -1635,1 +1635,3 @@
+def nocudalib : Flag<["-"], "nocudalib">,
+  HelpText<"Don't link with libraries necessary for running CUDA 
(-L/path/to/cuda/lib{,64} -lcudart_static -lrt -lpthread -ldl)">;
 def nocudalibdevice : Flag<["-"], "nocudalibdevice">,

Implementation details may be different on different platforms. I.e. you may 
need to link with different set of libraries if/when we add missing bits for 
windows and your help string will make no sense there.

Specifics should be in the documentation, IMO.




Comment at: lib/Driver/ToolChains.cpp:4130
@@ +4129,3 @@
+  LDArgs.push_back(DriverArgs.MakeArgString(CudaInstallation.getLibPath()));
+  for (const char *Flag : {"-lcudart_static", "-ldl", "-lrt", "-lpthread"}) {
+LDArgs.push_back(DriverArgs.MakeArgString(Flag));

{}, again.
:-)


http://reviews.llvm.org/D15596



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


r256983 - Only instantiate a default argument once.

2016-01-06 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed Jan  6 16:34:54 2016
New Revision: 256983

URL: http://llvm.org/viewvc/llvm-project?rev=256983&view=rev
Log:
Only instantiate a default argument once.

By storing the instantiated expression back in the ParmVarDecl,
we remove the last need for separately storing the sub-expression
of a CXXDefaultArgExpr.  This makes PCH/Modules merging quite
simple: CXXDefaultArgExpr records are serialized as references
to the ParmVarDecl, and we ignore redundant attempts to overwrite
the instantiated expression.

This has some extremely marginal impact on user-facing semantics.
However, the major effect is that it avoids IRGen errors about
conflicting definitions due to lambdas in the argument being
instantiated multiple times while sharing the same mangling.
It should also slightly improve memory usage and module file size.

rdar://23810407

Added:
cfe/trunk/test/PCH/chain-default-argument-instantiation.cpp
Modified:
cfe/trunk/include/clang/AST/ASTMutationListener.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Serialization/ASTCommon.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/SemaCXX/conversion.cpp
cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp

Modified: cfe/trunk/include/clang/AST/ASTMutationListener.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTMutationListener.h?rev=256983&r1=256982&r2=256983&view=diff
==
--- cfe/trunk/include/clang/AST/ASTMutationListener.h (original)
+++ cfe/trunk/include/clang/AST/ASTMutationListener.h Wed Jan  6 16:34:54 2016
@@ -29,6 +29,7 @@ namespace clang {
   class ObjCContainerDecl;
   class ObjCInterfaceDecl;
   class ObjCPropertyDecl;
+  class ParmVarDecl;
   class QualType;
   class RecordDecl;
   class TagDecl;
@@ -88,6 +89,9 @@ public:
   /// \brief A function template's definition was instantiated.
   virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {}
 
+  /// \brief A default argument was instantiated.
+  virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {}
+
   /// \brief A new objc category class was added for an interface.
   virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
 const ObjCInterfaceDecl *IFD) {}

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=256983&r1=256982&r2=256983&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Jan  6 16:34:54 2016
@@ -951,15 +951,9 @@ public:
 /// This wraps up a function call argument that was created from the
 /// corresponding parameter's default argument, when the call did not
 /// explicitly supply arguments for all of the parameters.
-class CXXDefaultArgExpr final
-: public Expr,
-  private llvm::TrailingObjects {
+class CXXDefaultArgExpr final : public Expr {
   /// \brief The parameter whose default is being used.
-  ///
-  /// When the bit is set, the subexpression is stored after the
-  /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's
-  /// actual default expression is the subexpression.
-  llvm::PointerIntPair Param;
+  ParmVarDecl *Param;
 
   /// \brief The location where the default argument expression was used.
   SourceLocation Loc;
@@ -971,16 +965,7 @@ class CXXDefaultArgExpr final
  : param->getDefaultArg()->getType(),
param->getDefaultArg()->getValueKind(),
param->getDefaultArg()->getObjectKind(), false, false, false, 
false),
-  Param(param, false), Loc(Loc) { }
-
-  CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param,
-Expr *SubExpr)
-: Expr(SC, SubExpr->getType(),
-   SubExpr->getValueKind(), SubExpr->getObjectKind(),
-   false, false, false, false),
-  Param(param, true), Loc(Loc) {
-*getTrailingObjects() = SubExpr;
-  }
+  Param(param), Loc(Loc) { }
 
 public:
   CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {}
@@ -992,24 +977,15 @@ public:
 return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param);
   }
 
-  // \p Param is the parameter whose default argument is used by this
-  // expression, and \p SubExpr is the expression that will actually be used.
-  static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
-   ParmVarDecl *Param, Expr *SubExpr);
-
   // Retrieve the 

Re: [PATCH] D15443: Fix getLocEnd for function declarations with exception specification.

2016-01-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Sorry for the delay in reviewing this!

In terms of a test case, presumably you need this because a diagnostic location 
is incorrect -- would it be possible to write the exception specification such 
that it is on its own line, and then expect-warning|error|note on the new line 
instead? e.g.,

  void f()
  noexcept(that does something diagnosable); // expected-warning {{some 
diagnostic}}

I'm not too keen on adding the change without a test case because we may 
accidentally break it again in the future. However, the general gist of the 
code looks correct to me.


http://reviews.llvm.org/D15443



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


r256985 - PR26048, PR26050: put non-type template parameters and indirect field decls

2016-01-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  6 16:49:11 2016
New Revision: 256985

URL: http://llvm.org/viewvc/llvm-project?rev=256985&view=rev
Log:
PR26048, PR26050: put non-type template parameters and indirect field decls
into IDNS_Tag in C++, because they conflict with redeclarations of tags. (This
doesn't affect elaborated-type-specifier lookup, which looks for IDNS_Type in
C++).

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp
cfe/trunk/test/CXX/temp/temp.res/temp.local/p6.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=256985&r1=256984&r2=256985&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Jan  6 16:49:11 2016
@@ -2440,10 +2440,9 @@ class IndirectFieldDecl : public ValueDe
   NamedDecl **Chaining;
   unsigned ChainingSize;
 
-  IndirectFieldDecl(DeclContext *DC, SourceLocation L,
+  IndirectFieldDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
 DeclarationName N, QualType T,
-NamedDecl **CH, unsigned CHS)
-: ValueDecl(IndirectField, DC, L, N, T), Chaining(CH), ChainingSize(CHS) {}
+NamedDecl **CH, unsigned CHS);
 
 public:
   static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC,

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=256985&r1=256984&r2=256985&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Jan  6 16:49:11 2016
@@ -4024,16 +4024,26 @@ EnumConstantDecl::CreateDeserialized(AST
 
 void IndirectFieldDecl::anchor() { }
 
+IndirectFieldDecl::IndirectFieldDecl(ASTContext &C, DeclContext *DC,
+ SourceLocation L, DeclarationName N,
+ QualType T, NamedDecl **CH, unsigned CHS)
+: ValueDecl(IndirectField, DC, L, N, T), Chaining(CH), ChainingSize(CHS) {
+  // In C++, indirect field declarations conflict with tag declarations in the
+  // same scope, so add them to IDNS_Tag so that tag redeclaration finds them.
+  if (C.getLangOpts().CPlusPlus)
+IdentifierNamespace |= IDNS_Tag;
+}
+
 IndirectFieldDecl *
 IndirectFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
   IdentifierInfo *Id, QualType T, NamedDecl **CH,
   unsigned CHS) {
-  return new (C, DC) IndirectFieldDecl(DC, L, Id, T, CH, CHS);
+  return new (C, DC) IndirectFieldDecl(C, DC, L, Id, T, CH, CHS);
 }
 
 IndirectFieldDecl *IndirectFieldDecl::CreateDeserialized(ASTContext &C,
  unsigned ID) {
-  return new (C, ID) IndirectFieldDecl(nullptr, SourceLocation(),
+  return new (C, ID) IndirectFieldDecl(C, nullptr, SourceLocation(),
DeclarationName(), QualType(), nullptr,
0);
 }

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=256985&r1=256984&r2=256985&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Jan  6 16:49:11 2016
@@ -569,7 +569,6 @@ unsigned Decl::getIdentifierNamespaceFor
 case Var:
 case ImplicitParam:
 case ParmVar:
-case NonTypeTemplateParm:
 case ObjCMethod:
 case ObjCProperty:
 case MSProperty:
@@ -579,6 +578,12 @@ unsigned Decl::getIdentifierNamespaceFor
 case IndirectField:
   return IDNS_Ordinary | IDNS_Member;
 
+case NonTypeTemplateParm:
+  // Non-type template parameters are not found by lookups that ignore
+  // non-types, but they are found by redeclaration lookups for tag types,
+  // so we include them in the tag namespace.
+  return IDNS_Ordinary | IDNS_Tag;
+
 case ObjCCompatibleAlias:
 case ObjCInterface:
   return IDNS_Ordinary | IDNS_Type;

Modified: cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp?rev=256985&r1=256984&r2=256985&view=diff
==
--- cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp (original)
+++ cfe/trunk/test/CXX/class/class.union/class.union.anon/p1.cpp Wed Jan  6 
16:49:11 2016
@@ -13,14 +13,12 @@ struct X {
 int d; // expected-error {{member of anonymous union redeclares}}
 int e; // expected-note {{previous}}
 int f; // expected-note {{previous}}
-int g;
+int 

Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Jason Henline via cfe-commits
jhen added inline comments.


Comment at: include/clang/AST/ExprCXX.h:181
@@ +180,3 @@
+assert(
+!IsConfigSet &&
+"CUDAKernelCallExpr.setConfig can only be called once per instance.");

rsmith wrote:
> Perhaps `assert(!getPreArg(CONFIG))` instead of storing a separate flag?
Yes, I think that is much nicer. But I am worried that the config pre-arg might 
not be initialized before I check it, so in my next revision of this patch I've 
also added code in the CallExpr constructors to make sure that pre-args are 
always initialized to zero.

Unfortunately, the simple way to do this leads to the entire array of function 
argument pointers being initialized for every function call expression 
construction (not just CUDA calls). Do you think I should try to avoid this 
overhead by only initializing the pre-arguments (either in the CallExpr code 
for everyone to share, or just in the CUDA code)?


Comment at: test/SemaCUDA/kernel-call.cu:27
@@ -26,1 +26,3 @@
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }

rsmith wrote:
> Your approach for that testcase seems fine, but it's not a test for the right 
> thing as it doesn't have an unexpanded pack within the kernel call args. 
> Here's a testcase for that scenario:
> 
>   template void kernel_wrapper() {
> void (*fs[])() = {
>   []{ kernel<<>>(); } ...
> };
>   }
Excellent! Thank you for that test case. I suspected that I wasn't really 
exercising the "unexpanded" parameter pack with my code.


http://reviews.llvm.org/D15858



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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-06 Thread Jason Henline via cfe-commits
jhen updated this revision to Diff 44167.
jhen added a comment.

- Use config ptr itself rather than boolean flag


http://reviews.llvm.org/D15858

Files:
  include/clang/AST/ExprCXX.h
  lib/AST/Expr.cpp
  test/SemaCUDA/kernel-call.cu

Index: test/SemaCUDA/kernel-call.cu
===
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
 
   int (*fp)(int) = h2;
   fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1148,7 +1148,7 @@
  fn->containsUnexpandedParameterPack()),
 NumArgs(args.size()) {
 
-  SubExprs = new (C) Stmt*[args.size()+PREARGS_START+NumPreArgs];
+  SubExprs = new (C) Stmt*[args.size()+PREARGS_START+NumPreArgs]();
   SubExprs[FN] = fn;
   for (unsigned i = 0; i != args.size(); ++i) {
 if (args[i]->isTypeDependent())
@@ -1179,7 +1179,7 @@
EmptyShell Empty)
   : Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) {
   // FIXME: Why do we allocate this?
-  SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs];
+  SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs]();
   CallExprBits.NumPreArgs = NumPreArgs;
 }
 
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -171,7 +171,18 @@
 return cast_or_null(getPreArg(CONFIG));
   }
   CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
-  void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
+
+  /// \brief Sets the kernel configuration expression.
+  ///
+  /// Note that this method can only be called once per class instance.
+  void setConfig(CallExpr *E) {
+assert(
+!getConfig() &&
+"CUDAKernelCallExpr.setConfig can only be called once per instance.");
+setPreArg(CONFIG, E);
+setInstantiationDependent(isInstantiationDependent() ||
+  E->isInstantiationDependent());
+  }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CUDAKernelCallExprClass;


Index: test/SemaCUDA/kernel-call.cu
===
--- test/SemaCUDA/kernel-call.cu
+++ test/SemaCUDA/kernel-call.cu
@@ -23,4 +23,6 @@
 
   int (*fp)(int) = h2;
   fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
 }
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1148,7 +1148,7 @@
  fn->containsUnexpandedParameterPack()),
 NumArgs(args.size()) {
 
-  SubExprs = new (C) Stmt*[args.size()+PREARGS_START+NumPreArgs];
+  SubExprs = new (C) Stmt*[args.size()+PREARGS_START+NumPreArgs]();
   SubExprs[FN] = fn;
   for (unsigned i = 0; i != args.size(); ++i) {
 if (args[i]->isTypeDependent())
@@ -1179,7 +1179,7 @@
EmptyShell Empty)
   : Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) {
   // FIXME: Why do we allocate this?
-  SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs];
+  SubExprs = new (C) Stmt*[PREARGS_START+NumPreArgs]();
   CallExprBits.NumPreArgs = NumPreArgs;
 }
 
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -171,7 +171,18 @@
 return cast_or_null(getPreArg(CONFIG));
   }
   CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
-  void setConfig(CallExpr *E) { setPreArg(CONFIG, E); }
+
+  /// \brief Sets the kernel configuration expression.
+  ///
+  /// Note that this method can only be called once per class instance.
+  void setConfig(CallExpr *E) {
+assert(
+!getConfig() &&
+"CUDAKernelCallExpr.setConfig can only be called once per instance.");
+setPreArg(CONFIG, E);
+setInstantiationDependent(isInstantiationDependent() ||
+  E->isInstantiationDependent());
+  }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CUDAKernelCallExprClass;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44170.
jlebar marked 2 inline comments as done.
jlebar added a comment.

Address tra's review comments.


http://reviews.llvm.org/D15596

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/cuda-default-libs.cu

Index: test/Driver/cuda-default-libs.cu
===
--- /dev/null
+++ test/Driver/cuda-default-libs.cu
@@ -0,0 +1,42 @@
+// Checks that we add -L /path/to/cuda/lib{,64} and -lcudart_static -ldl -lrt
+// -lpthread as appropriate when compiling CUDA code.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   -lfoo --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_32
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   -lfoo --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_64
+//
+// # Our new flags should come after user-specified flags.
+// CUDA: -lfoo
+// CUDA-x86_32: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-x86_64: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_32-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_64-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-DAG: "-lcudart_static"
+// CUDA-DAG: "-ldl"
+// CUDA-DAG: "-lrt"
+// CUDA-DAG: "-lpthread"
+
+// If we can't find CUDA, don't include it in our library search path, and
+// don't include any additional libraries via -l.
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/no-cuda-there %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// Also don't add anything if we pass -nocudalib.
+// RUN: %clang -### -v --target=x86_64-unknown-linux -nocudalib \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// NOCUDA-NOT: "-L" "{{.*}}/no-cuda-there/{{.*}}"
+// NOCUDA-NOT: "-lcudart_static"
+// NOCUDA-NOT: "-ldl"
+// NOCUDA-NOT: "-lrt"
+// NOCUDA-NOT: "-lpthread"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -224,8 +224,16 @@
   }
 }
 
-static void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
-const ArgList &Args, ArgStringList &CmdArgs) {
+// Is the given action, or any of its inputs, a CUDA action?
+static bool isCudaAction(const Action* A) {
+  return isa(A) || isa(A) ||
+ std::any_of(A->getInputs().begin(), A->getInputs().end(),
+ isCudaAction);
+}
+
+static void AddLinkerInputs(const Compilation &C, const ToolChain &TC,
+const InputInfoList &Inputs, const ArgList &Args,
+ArgStringList &CmdArgs) {
   const Driver &D = TC.getDriver();
 
   // Add extra linker input arguments which are not treated as inputs
@@ -264,6 +272,10 @@
   //and only supported on native toolchains.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+  // Add -L/path/to/cuda/lib if any of our inputs are .cu files.
+  if (std::any_of(C.getActions().begin(), C.getActions().end(), isCudaAction))
+TC.AddCudaLinkerArgs(Args, CmdArgs);
 }
 
 /// \brief Determine whether Objective-C automated reference counting is
@@ -6409,7 +6421,7 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_u_Group});
 
-  AddLinkerInputs(HTC, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, HTC, Inputs, Args, CmdArgs);
 
   //
   // Libraries
@@ -6472,7 +6484,7 @@
   CmdArgs.push_back("old-gnu");
   CmdArgs.push_back("-target");
   CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
@@ -6500,7 +6512,7 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Linker, CmdArgs, Inputs));
@@ -6803,7 +6815,7 @@
   if (D.isUsingLTO())
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
 
-  AddLinke

Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Driver/Options.td:1636
@@ -1635,1 +1635,3 @@
+def nocudalib : Flag<["-"], "nocudalib">,
+  HelpText<"Don't link with libraries necessary for running CUDA 
(-L/path/to/cuda/lib{,64} -lcudart_static -lrt -lpthread -ldl)">;
 def nocudalibdevice : Flag<["-"], "nocudalibdevice">,

tra wrote:
> Implementation details may be different on different platforms. I.e. you may 
> need to link with different set of libraries if/when we add missing bits for 
> windows and your help string will make no sense there.
> 
> Specifics should be in the documentation, IMO.
> 
> 
OK, that's a good reason not to do it in the command-line help.


http://reviews.llvm.org/D15596



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


Re: [PATCH] D13330: Implement __attribute__((unique_instantiation))

2016-01-06 Thread Keno Fischer via cfe-commits
loladiro added a comment.

Bumping this again.


http://reviews.llvm.org/D13330



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


Re: [PATCH] D15456: [PATCH] New diagnostic for non-idiomatic copy or move operations (v2)

2016-01-06 Thread Richard Smith via cfe-commits
rsmith added a comment.

I'm unconvinced this meets the bar for an on-by-default warning. Your suggested 
workaround for correct-but-diagnosed code doesn't seem to work: if I have

  struct X {
X(const volatile X&);
  };

... adding

  X(const X&) = delete;

or a private "normal" copy constructor will break clients of my code that 
happen to have a non-volatile `X` object. This will also diagnose the pre-C++11 
idiom of:

  struct noncopyable {
noncopyable(noncopyable&);
void operator=(noncopyable&);
  };

... where the references are deliberately references to non-const in order to 
allow more bugs to be caught at compile time.

I'd also expect that if the user wrote more tokens than would be present in the 
idiomatic declaration, they probably know what they're doing (so don't reject 
extra cv-qualifiers and ref-qualifiers).

Can you provide a list of the things this found in Qt and rethinkdb? Is there 
some pattern in them? Are they bugs?



Comment at: lib/Sema/SemaDeclCXX.cpp:4924-4929
@@ +4923,8 @@
+   bool Move) {
+  // Check that there are no ref-qualifiers.
+  if (Assign->getRefQualifier() != RQ_None) {
+S.Diag(Assign->getLocation(), diag::warn_non_idiomatic_copy_move_assign)
+<< Move << /*ref-qualifier*/ 2;
+return;
+  }
+

I don't think it makes sense to warn on this when the qualifier is `&`. In that 
case, the user's code is *better* than the normal idiom. And if they used the 
ref-qualifier `&&`, perhaps we should just assume they know what they're doing?


http://reviews.llvm.org/D15456



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


r256996 - Properly bind up any cleanups in an ExprWithCleanups after

2016-01-06 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed Jan  6 17:34:20 2016
New Revision: 256996

URL: http://llvm.org/viewvc/llvm-project?rev=256996&view=rev
Log:
Properly bind up any cleanups in an ExprWithCleanups after
instantiating a default argument expression.

This was previously just working implicitly by reinstantiating
in the current context, but caching means that we weren't
registering cleanups in subsequent uses.

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

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=256996&r1=256995&r2=256996&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan  6 17:34:20 2016
@@ -4313,17 +4313,16 @@ ExprResult Sema::BuildCXXDefaultArgExpr(
 if (Result.isInvalid())
   return ExprError();
 
-Expr *Arg = Result.getAs();
-CheckCompletedExpr(Arg, Param->getOuterLocStart());
+Result = ActOnFinishFullExpr(Result.getAs(),
+ Param->getOuterLocStart());
+if (Result.isInvalid())
+  return ExprError();
 
 // Remember the instantiated default argument.
-Param->setDefaultArg(Arg);
+Param->setDefaultArg(Result.getAs());
 if (ASTMutationListener *L = getASTMutationListener()) {
   L->DefaultArgumentInstantiated(Param);
 }
-
-// Build the default argument expression.
-return CXXDefaultArgExpr::Create(Context, CallLoc, Param);
   }
 
   // If the default expression creates temporaries, we need to


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


Re: r256967 - [WebAssembly] Add --gc-sections to the link line.

2016-01-06 Thread Joerg Sonnenberger via cfe-commits
On Wed, Jan 06, 2016 at 07:43:32PM -, Dan Gohman via cfe-commits wrote:
> Author: djg
> Date: Wed Jan  6 13:43:32 2016
> New Revision: 256967
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256967&view=rev
> Log:
> [WebAssembly] Add --gc-sections to the link line.

Can you make sure it is added before any user options, so that in the
worst case it can still be overriden?

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


[PATCH] D15939: Pass the Compilation as an arg to AddLinkerInputs.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added reviewers: tra, echristo.
jlebar added a subscriber: cfe-commits.

Currently this arg is unused; a use is added in D15596.

http://reviews.llvm.org/D15939

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -224,8 +224,9 @@
   }
 }
 
-static void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
-const ArgList &Args, ArgStringList &CmdArgs) {
+static void AddLinkerInputs(const Compilation &C, const ToolChain &TC,
+const InputInfoList &Inputs, const ArgList &Args,
+ArgStringList &CmdArgs) {
   const Driver &D = TC.getDriver();
 
   // Add extra linker input arguments which are not treated as inputs
@@ -6409,7 +6410,7 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_u_Group});
 
-  AddLinkerInputs(HTC, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, HTC, Inputs, Args, CmdArgs);
 
   //
   // Libraries
@@ -6472,7 +6473,7 @@
   CmdArgs.push_back("old-gnu");
   CmdArgs.push_back("-target");
   CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
@@ -6500,7 +6501,7 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Linker, CmdArgs, Inputs));
@@ -6803,7 +6804,7 @@
   if (D.isUsingLTO())
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
 
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, ToolChain, Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (D.CCCIsCXX())
@@ -7173,7 +7174,7 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   // Build the input file for -filelist (list of linker input files) in case we
   // need it later
   for (const auto &II : Inputs) {
@@ -7391,7 +7392,7 @@
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_r});
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (getToolChain().getDriver().CCCIsCXX())
@@ -7564,7 +7565,7 @@
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (D.CCCIsCXX()) {
@@ -7683,7 +7684,7 @@
   Args.AddAllArgs(CmdArgs,
   {options::OPT_L, options::OPT_T_Group, options::OPT_e});
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (D.CCCIsCXX()) {
@@ -7949,7 +7950,7 @@
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, ToolChain, Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 addOpenMPRuntime(CmdArgs, ToolChain, Args);
@@ -8245,7 +8246,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
   Args.AddAllArgs(CmdArgs, options::OPT_r);
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
 
   unsigned Major, Minor, Micro;
   getToolChain().getTriple().getOSVersion(Major, Minor, Micro);
@@ -8832,7 +8833,7 @@
 CmdArgs.push_back("--no-demangle");
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, ToolChain, Inputs, Args, CmdArgs);
   // The profile runtime also needs access to system libraries.
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 
@@ -9026,7 +9027,7 @@
   if (Args.hasA

Re: r256996 - Properly bind up any cleanups in an ExprWithCleanups after

2016-01-06 Thread Richard Smith via cfe-commits
On Wed, Jan 6, 2016 at 3:34 PM, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rjmccall
> Date: Wed Jan  6 17:34:20 2016
> New Revision: 256996
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256996&view=rev
> Log:
> Properly bind up any cleanups in an ExprWithCleanups after
> instantiating a default argument expression.
>
> This was previously just working implicitly by reinstantiating
> in the current context, but caching means that we weren't
> registering cleanups in subsequent uses.
>

Isn't the code you changed below only reached the first time anyway, now
that we only instantiate the default argument once?


> Modified:
> cfe/trunk/lib/Sema/SemaExpr.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=256996&r1=256995&r2=256996&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan  6 17:34:20 2016
> @@ -4313,17 +4313,16 @@ ExprResult Sema::BuildCXXDefaultArgExpr(
>  if (Result.isInvalid())
>return ExprError();
>
> -Expr *Arg = Result.getAs();
> -CheckCompletedExpr(Arg, Param->getOuterLocStart());
> +Result = ActOnFinishFullExpr(Result.getAs(),
> + Param->getOuterLocStart());
> +if (Result.isInvalid())
> +  return ExprError();
>
>  // Remember the instantiated default argument.
> -Param->setDefaultArg(Arg);
> +Param->setDefaultArg(Result.getAs());
>  if (ASTMutationListener *L = getASTMutationListener()) {
>L->DefaultArgumentInstantiated(Param);
>  }
> -
> -// Build the default argument expression.
> -return CXXDefaultArgExpr::Create(Context, CallLoc, Param);
>}
>
>// If the default expression creates temporaries, we need to
>
>
> ___
> 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] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44178.
jlebar added a comment.

Split out the bits adding an arg to AddLinkerInputs into a separate patch, 
http://reviews.llvm.org/D15939.


http://reviews.llvm.org/D15596

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/cuda-default-libs.cu

Index: test/Driver/cuda-default-libs.cu
===
--- /dev/null
+++ test/Driver/cuda-default-libs.cu
@@ -0,0 +1,42 @@
+// Checks that we add -L /path/to/cuda/lib{,64} and -lcudart_static -ldl -lrt
+// -lpthread as appropriate when compiling CUDA code.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   -lfoo --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_32
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   -lfoo --sysroot=%S/Inputs/CUDA %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix CUDA -check-prefix CUDA-x86_64
+//
+// # Our new flags should come after user-specified flags.
+// CUDA: -lfoo
+// CUDA-x86_32: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-x86_64: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_32-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+// CUDA-x86_64-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// CUDA-DAG: "-lcudart_static"
+// CUDA-DAG: "-ldl"
+// CUDA-DAG: "-lrt"
+// CUDA-DAG: "-lpthread"
+
+// If we can't find CUDA, don't include it in our library search path, and
+// don't include any additional libraries via -l.
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/no-cuda-there %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// Also don't add anything if we pass -nocudalib.
+// RUN: %clang -### -v --target=x86_64-unknown-linux -nocudalib \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+//
+// NOCUDA-NOT: "-L" "{{.*}}/no-cuda-there/{{.*}}"
+// NOCUDA-NOT: "-lcudart_static"
+// NOCUDA-NOT: "-ldl"
+// NOCUDA-NOT: "-lrt"
+// NOCUDA-NOT: "-lpthread"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -224,6 +224,13 @@
   }
 }
 
+// Is the given action, or any of its inputs, a CUDA action?
+static bool isCudaAction(const Action* A) {
+  return isa(A) || isa(A) ||
+ std::any_of(A->getInputs().begin(), A->getInputs().end(),
+ isCudaAction);
+}
+
 static void AddLinkerInputs(const Compilation &C, const ToolChain &TC,
 const InputInfoList &Inputs, const ArgList &Args,
 ArgStringList &CmdArgs) {
@@ -265,6 +272,10 @@
   //and only supported on native toolchains.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+  // Add -L/path/to/cuda/lib if any of our inputs are .cu files.
+  if (std::any_of(C.getActions().begin(), C.getActions().end(), isCudaAction))
+TC.AddCudaLinkerArgs(Args, CmdArgs);
 }
 
 /// \brief Determine whether Objective-C automated reference counting is
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -796,6 +796,8 @@
   llvm::opt::ArgStringList &CC1Args) const override;
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCudaLinkerArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4120,6 +4120,17 @@
   }
 }
 
+void Linux::AddCudaLinkerArgs(const ArgList &DriverArgs,
+  ArgStringList &LDArgs) const {
+  if (DriverArgs.hasArg(options::OPT_nocudalib) || !CudaInstallation.isValid())
+return;
+
+  LDArgs.push_back("-L");
+  LDArgs.push_back(DriverArgs.MakeArgString(CudaInstallation.getLibPath()));
+  for (const char *Flag : {"-lcudart_static", "-ldl", "-lrt", "-lpthread"})
+LDArgs.push_back(DriverArgs.MakeArgString(Flag));
+}
+
 bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask Linux::getSupportedSanitizers() const {
Index: lib/Driver/ToolChain.cpp

Re: [PATCH] D15939: Pass the Compilation as an arg to AddLinkerInputs.

2016-01-06 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D15939



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


Re: r256996 - Properly bind up any cleanups in an ExprWithCleanups after

2016-01-06 Thread John McCall via cfe-commits
> On Jan 6, 2016, at 3:54 PM, Richard Smith  wrote:
> On Wed, Jan 6, 2016 at 3:34 PM, John McCall via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: rjmccall
> Date: Wed Jan  6 17:34:20 2016
> New Revision: 256996
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256996&view=rev 
> 
> Log:
> Properly bind up any cleanups in an ExprWithCleanups after
> instantiating a default argument expression.
> 
> This was previously just working implicitly by reinstantiating
> in the current context, but caching means that we weren't
> registering cleanups in subsequent uses.
> 
> Isn't the code you changed below only reached the first time anyway, now that 
> we only instantiate the default argument once?

Yes.  The difference is that Param->getInit() will now be wrapped in an
ExprWithCleanups (assuming it does contain cleanups).  This means that on
subsequent calls, the standard logic beneath this will now flag the existence
of those cleanups, ultimately causing the containing full-expression to also
get wrapped.  That’s what wasn’t happening before, causing cleanups to
escape into the surrounding context, which apparently was only checked
by some OpenMP tests.

(CXXDefaultArgExpr::getExpr() looks through the ExprWithCleanups, and
that’s what’s used by CodeGen and other clients.)

John.


>  
> Modified:
> cfe/trunk/lib/Sema/SemaExpr.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=256996&r1=256995&r2=256996&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan  6 17:34:20 2016
> @@ -4313,17 +4313,16 @@ ExprResult Sema::BuildCXXDefaultArgExpr(
>  if (Result.isInvalid())
>return ExprError();
> 
> -Expr *Arg = Result.getAs();
> -CheckCompletedExpr(Arg, Param->getOuterLocStart());
> +Result = ActOnFinishFullExpr(Result.getAs(),
> + Param->getOuterLocStart());
> +if (Result.isInvalid())
> +  return ExprError();
> 
>  // Remember the instantiated default argument.
> -Param->setDefaultArg(Arg);
> +Param->setDefaultArg(Result.getAs());
>  if (ASTMutationListener *L = getASTMutationListener()) {
>L->DefaultArgumentInstantiated(Param);
>  }
> -
> -// Build the default argument expression.
> -return CXXDefaultArgExpr::Create(Context, CallLoc, Param);
>}
> 
>// If the default expression creates temporaries, we need to
> 
> 
> ___
> 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] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Driver/Tools.cpp:276
@@ +275,3 @@
+
+  // Add -L/path/to/cuda/lib if any of our inputs are .cu files.
+  if (std::any_of(C.getActions().begin(), C.getActions().end(), isCudaAction))

It just struck me that this patch may not be as useful as we'd like it to be.

For typical compilation source-to-object and object-to-executable are separate 
phases.
We need these flags during linking phase, but we will rarely see any CUDA 
inputs passed to clang. Most of the time we'll be dealing with .o files and 
will have no way to tell whether those were compiled from CUDA sources. :-(



http://reviews.llvm.org/D15596



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


Re: [PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2016-01-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno updated this revision to Diff 44180.
bruno added a comment.

Hi Richard,

Thanks for the comments. Updated the patch!

In http://reviews.llvm.org/D15173#313235, @rsmith wrote:

> I think that this will leave us with a broken token stream. In your example, 
> the cached token stream starts as
>
>   `NSArray` `<` `id` `<` `PB` `>>` `*` [...]
>   
>
> ... and we try to annotate the `id` with our `CachedLexPos` pointing at 
> the `*` token. That leaves `CachedTokens` containing:
>
>   `NSArray` `<` `(type annotation)` `*` [...]
>   
>
> ... which is wrong. We need to actually convert the `tok::greatergreater` in 
> `CachedTokens` into a `tok::greater` and update its location and length in 
> order for the cached token stream to be correctly updated. Otherwise if the 
> parser backtracks it will see the wrong token stream.


I don't think this happens, the type annotation starts at 7:11 and ends at 7:24:
identifier 'NSArray'Loc=
greatergreater '>>' Loc=

The code that follows the assert then patches the CachedTokens the correct way, 
see the CachedTokens before and after:

- Before:

(clang::Preprocessor::CachedTokensTy) $32 = {

  [0] = (Loc = 89, UintData = 1, PtrData = 0x, Kind = l_paren, 
Flags = 0)
  [1] = (Loc = 90, UintData = 7, PtrData = 0x00010d82fba0, Kind = 
identifier, Flags = 0)
  [2] = (Loc = 97, UintData = 1, PtrData = 0x, Kind = less, 
Flags = 0)
  [3] = (Loc = 98, UintData = 2, PtrData = 0x00010d01da58, Kind = 
identifier, Flags = 0)
  [4] = (Loc = 100, UintData = 1, PtrData = 0x, Kind = less, 
Flags = 0)
  [5] = (Loc = 101, UintData = 2, PtrData = 0x00010d82fb70, Kind = 
identifier, Flags = 0)
  [6] = (Loc = 103, UintData = 2, PtrData = 0x, Kind = 
greatergreater, Flags = 0)
  [7] = (Loc = 106, UintData = 1, PtrData = 0x, Kind = star, 
Flags = 2)

}

- After:

(clang::Preprocessor::CachedTokensTy) $34 = {

  [0] = (Loc = 89, UintData = 1, PtrData = 0x, Kind = l_paren, 
Flags = 0)
  [1] = (Loc = 90, UintData = 104, PtrData = 0x00010d820660, Kind = 
annot_typename, Flags = 0)
  [2] = (Loc = 106, UintData = 1, PtrData = 0x, Kind = star, 
Flags = 2)

}


http://reviews.llvm.org/D15173

Files:
  lib/Lex/PPCaching.cpp
  test/Parser/objcxx11-protocol-in-template.mm

Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,3 +8,11 @@
 
 vector> v;
 vector>> v2;
+
+@protocol PA;
+@protocol PB;
+
+@class NSArray;
+typedef int some_t;
+
+id FA(NSArray> *h, some_t group);
Index: lib/Lex/PPCaching.cpp
===
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -97,13 +97,33 @@
 void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
   assert(Tok.isAnnotation() && "Expected annotation token");
   assert(CachedLexPos != 0 && "Expected to have some cached tokens");
-  assert(CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc()
- && "The annotation should be until the most recent cached token");
+
+#ifndef NDEBUG
+  {
+Token CachedLastTok = CachedTokens[CachedLexPos - 1];
+SourceLocation CachedLastTokLoc = CachedLastTok.getLastLoc();
+SourceLocation TokAnnEndLoc = Tok.getAnnotationEndLoc();
+
+// The annotation should be until the most recent cached token. Since
+// `Tok` length could be bigger than one (e.g. greatergreater '>>'), 
account
+// for that case before checking the assertion.
+if (CachedLastTokLoc != TokAnnEndLoc && !CachedLastTok.isAnnotation()) {
+  CachedLastTokLoc =
+  CachedLastTokLoc.getLocWithOffset(CachedLastTok.getLength());
+  unsigned TokAnnEndLocSize = Lexer::MeasureTokenLength(
+  SourceMgr.getSpellingLoc(TokAnnEndLoc), SourceMgr, LangOpts);
+  TokAnnEndLoc = TokAnnEndLoc.getLocWithOffset(TokAnnEndLocSize);
+}
+
+assert(CachedLastTokLoc == TokAnnEndLoc &&
+   "The annotation should be until the most recent cached token");
+  }
+#endif
 
   // Start from the end of the cached tokens list and look for the token
   // that is the beginning of the annotation token.
   for (CachedTokensTy::size_type i = CachedLexPos; i != 0; --i) {
-CachedTokensTy::iterator AnnotBegin = CachedTokens.begin() + i-1;
+CachedTokensTy::iterator AnnotBegin = CachedTokens.begin() + i - 1;
 if (AnnotBegin->getLocation() == Tok.getLocation()) {
   assert((BacktrackPositions.empty() || BacktrackPositions.back() < i) &&
  "The backtrack pos points inside the annotated tokens!");


Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,

Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar abandoned this revision.
jlebar added a comment.

> It just struck me that this patch may not be as useful as we'd like it to be.


Oh.  Yes.

I guess I'll drop this and http://reviews.llvm.org/D15939.  :(


http://reviews.llvm.org/D15596



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


Re: [PATCH] D15939: Pass the Compilation as an arg to AddLinkerInputs.

2016-01-06 Thread Justin Lebar via cfe-commits
jlebar abandoned this revision.
jlebar added a comment.

Per http://reviews.llvm.org/D15596, this actually doesn't help us.  Oops.


http://reviews.llvm.org/D15939



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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-06 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4992
@@ +4991,3 @@
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",

aaron.ballman wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > > I'm happy to make the improvement, but I don't know how. I simply call 
> > > > the Node.underlyingType(), just like hasType calls Node.getType(). I 
> > > > don't know why they are different.
> > > 
> > > hasType() and hasUnderlyingType() have different operational semantic 
> > > implications, at least to me. hasType() asks, "ultimately, what is the 
> > > type of this thing?", and Node.underlyingType() answers that. To me, 
> > > hasUnderlyingType() asks, "in the chain of types that this typedef refers 
> > > to, does this thing match any of them?", and Node.underlyingType() does 
> > > not answer that -- it only looks at the final desugared type. The 
> > > difference we want is that hasType() continues to look at the final type, 
> > > but hasUnderlyingType() needs to do more work to look at intermediary 
> > > types and terminate that loop when the answer is "yes, it has this type" 
> > > or "no, we can't desugar any further."
> > > 
> > > If we don't care about the intermediate types for your needs, then I 
> > > don't see the point to hasUnderlyingType() being an AST matcher at all. 
> > > hasType() does exactly what is needed, and you can instead modify that to 
> > > accept a TypedefDecl in addition to Expr and ValueDecl. However, I still 
> > > see value in hasUnderlyingType() because typedef chains can be long and 
> > > complex (like in the Win32 APIs), and being able to query for 
> > > intermediary types would be useful. e.g., I want to know about all types 
> > > that have an intermediary type of DWORD (which itself is a typedef for an 
> > > unsigned integer type). hasType() will always go to the final type, 
> > > making such a matcher impossible without something like 
> > > hasUnderlyingType().
> > I just named the matcher after the 
> > [accessor](http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html#a5fccedff6d3854db365a540145029158)
> >  on a typedefDecl node.  To me it's just a narrowing matcher on that node 
> > that gives you access to whatever the accessor returns.
> > 
> > Things may have changed in the meantime, but when I originally created this 
> > patch you couldn't do `typedefDecl(hasType(asString("int")))`.  It doesn't 
> > compile.  Since `hasType` just matched against the value of whatever 
> > `Node.getType()` returned it seemed natural to add a matcher called 
> > `hasUnderlyingType` that just matched against the value of whatever 
> > `Node.getUnderlyingType()` returned.
> > 
> > As I said, I'm happy to make the suggested improvement, but beyond simple 
> > immitation of existing matchers, I have no idea how to traverse the 
> > encodings of types within the guts of clang.  This is what I mean when I 
> > say "I don't know how".  I understand conceptually what you are saying but 
> > I have no idea how to express that in clang's code base.
> That's why I am trying to understand what your goal is. As best I can tell, 
> there are two distinct things someone may want to do with a typedef's type: 
> figure out what it ultimately boils down to, or traverse the typedef chain. I 
> was uncertain which one fit your needs better, but it sounds like "get the 
> ultimate type" is what you want. From there we can discuss what the proper 
> design of the matcher is. I think I was thrown off by you naming it 
> *has*UnderlyingType instead of *get*UnderlyingType because *has* implies a 
> different relationship than *get* and I couldn't see why you wouldn't just 
> update hasType() instead.
> 
> Another thing to think about: the typedef matcher is a bit controversial in 
> terms of the semantics, but the other matchers are not. Perhaps it makes 
> sense to split the patch into two parts?
> 
> As for how to actually implement the traversal, I think it looks something 
> like (totally untested):
> ```
> QualType QT = Context.getTypedefType(&Node);
> for (QualType NextQT; QT != NextQT; NextQT = 
> QT.getSingleStepDesugaredType(Context)) {
>   // If matches, return Type
> }
> return QT;
> ```
This all came up because of the work I was doing on clang-tidy to implement the 
modernize-redundant-void-arg check.  There wasn't a way to narrow typedefDecl 
nodes based on the actual type for which a synonym was being introduced.  In 
that situation, suppose we have something like this:

```
typedef void (fnReturningVoid)(void);
typedef foo fnReturningVoid;
```

I would want to match the first typedef because that is the one my check needs 
to modify.  I don't want to match the second typedef because even though it has 
the same ultimate type as the first, it doesn't contain the

r257004 - [WebAssembly] Only enable --gc-sections when optimizations are enabled.

2016-01-06 Thread Dan Gohman via cfe-commits
Author: djg
Date: Wed Jan  6 18:32:04 2016
New Revision: 257004

URL: http://llvm.org/viewvc/llvm-project?rev=257004&view=rev
Log:
[WebAssembly] Only enable --gc-sections when optimizations are enabled.

Also, revamp the wasm-toolchain.c test and add a test to ensure that
a user-supplied --no-gc-sections comes after --gc-sections.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257004&r1=257003&r2=257004&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 18:32:04 2016
@@ -6537,7 +6537,8 @@ void wasm::Linker::ConstructJob(Compilat
 
   // Enable garbage collection of unused input sections by default, since code
   // size is of particular importance.
-  CmdArgs.push_back("--gc-sections");
+  if (areOptimizationsEnabled(Args))
+CmdArgs.push_back("--gc-sections");
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257004&r1=257003&r2=257004&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan  6 18:32:04 2016
@@ -1,3 +1,23 @@
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown -x 
assembler %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
-// AS_LINK: clang{{.*}}" "-cc1as" {{.*}} "-o" "[[temp:[^"]*]]"
-// AS_LINK: lld{{.*}}" "-flavor" "ld" "--gc-sections" "[[temp]]" "-o" "a.out"
+// A basic clang -cc1 command-line.
+
+// RUN: %clang %s -### -target wasm32-unknown-unknown 2>&1 | FileCheck 
-check-prefix=CC1 %s
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}}
+
+// A basic C link command-line.
+
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown %s 
2>&1 | FileCheck -check-prefix=LINK %s
+// LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK: lld{{.*}}" "-flavor" "ld" "[[temp]]" "-o" "a.out"
+
+// A basic C link command-line with optimization.
+
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
%s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT: lld{{.*}}" "-flavor" "ld" "--gc-sections" "[[temp]]" "-o" "a.out"
+
+// Ditto, but ensure that a user --no-gc-sections comes after the
+// default --gc-sections.
+
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
-Wl,--no-gc-sections %s 2>&1 | FileCheck -check-prefix=NO_GC_SECTIONS %s
+// NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "ld" "--gc-sections" 
"--no-gc-sections" "[[temp]]" "-o" "a.out"


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


Re: r256967 - [WebAssembly] Add --gc-sections to the link line.

2016-01-06 Thread Dan Gohman via cfe-commits
On Wed, Jan 6, 2016 at 3:53 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Wed, Jan 06, 2016 at 07:43:32PM -, Dan Gohman via cfe-commits wrote:
> > Author: djg
> > Date: Wed Jan  6 13:43:32 2016
> > New Revision: 256967
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=256967&view=rev
> > Log:
> > [WebAssembly] Add --gc-sections to the link line.
>
> Can you make sure it is added before any user options, so that in the
> worst case it can still be overriden?


I've now added a test for this in r257004.

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


r257005 - [WebAssembly] Enable -ffunction-sections and -fdata-sections by default.

2016-01-06 Thread Dan Gohman via cfe-commits
Author: djg
Date: Wed Jan  6 18:50:27 2016
New Revision: 257005

URL: http://llvm.org/viewvc/llvm-project?rev=257005&view=rev
Log:
[WebAssembly] Enable -ffunction-sections and -fdata-sections by default.

These remain user-overridable with -fno-function-sections and
-fno-data-sections.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257005&r1=257004&r2=257005&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 18:50:27 2016
@@ -4176,8 +4176,11 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-generate-type-units");
   }
 
-  // CloudABI uses -ffunction-sections and -fdata-sections by default.
-  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI;
+  // CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
+  // default.
+  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI ||
+ Triple.getArch() == llvm::Triple::wasm32 ||
+ Triple.getArch() == llvm::Triple::wasm64;
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
options::OPT_fno_function_sections, UseSeparateSections)) {
@@ -6536,7 +6539,9 @@ void wasm::Linker::ConstructJob(Compilat
   CmdArgs.push_back("ld");
 
   // Enable garbage collection of unused input sections by default, since code
-  // size is of particular importance.
+  // size is of particular importance. This is significantly facilitated by
+  // the enabling of -ffunction-sections and -fdata-sections in
+  // Clang::ConstructJob.
   if (areOptimizationsEnabled(Args))
 CmdArgs.push_back("--gc-sections");
 

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257005&r1=257004&r2=257005&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan  6 18:50:27 2016
@@ -1,7 +1,19 @@
 // A basic clang -cc1 command-line.
 
 // RUN: %clang %s -### -target wasm32-unknown-unknown 2>&1 | FileCheck 
-check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}}
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-ffunction-sections" "-fdata-sections"
+
+// Ditto, but ensure that a user -fno-function-sections disables the
+// default -ffunction-sections.
+
+// RUN: %clang %s -### -target wasm32-unknown-unknown -fno-function-sections 
2>&1 | FileCheck -check-prefix=NO_FUNCTION_SECTIONS %s
+// NO_FUNCTION_SECTIONS-NOT: function-sections
+
+// Ditto, but ensure that a user -fno-data-sections disables the
+// default -fdata-sections.
+
+// RUN: %clang %s -### -target wasm32-unknown-unknown -fno-data-sections 2>&1 
| FileCheck -check-prefix=NO_DATA_SECTIONS %s
+// NO_DATA_SECTIONS-NOT: data-sections
 
 // A basic C link command-line.
 


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


r257006 - [WebAssembly] Enable -fvisibility=hidden by default.

2016-01-06 Thread Dan Gohman via cfe-commits
Author: djg
Date: Wed Jan  6 19:00:21 2016
New Revision: 257006

URL: http://llvm.org/viewvc/llvm-project?rev=257006&view=rev
Log:
[WebAssembly] Enable -fvisibility=hidden by default.

This, along with many things in the WebAssembly target, is experimental.
Feedback is welcome.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm32-unknown-unknown.cpp
cfe/trunk/test/Driver/wasm64-unknown-unknown.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257006&r1=257005&r2=257006&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 19:00:21 2016
@@ -2069,6 +2069,16 @@ void Clang::AddHexagonTargetArgs(const A
   CmdArgs.push_back("-machine-sink-split=0");
 }
 
+void Clang::AddWebAssemblyTargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Default to "hidden" visibility.
+  if (!Args.hasArg(options::OPT_fvisibility_EQ,
+   options::OPT_fvisibility_ms_compat)) {
+CmdArgs.push_back("-fvisibility");
+CmdArgs.push_back("hidden");
+  }
+}
+
 // Decode AArch64 features from string like +[no]featureA+[no]featureB+...
 static bool DecodeAArch64Features(const Driver &D, StringRef text,
   std::vector &Features) {
@@ -4015,6 +4025,11 @@ void Clang::ConstructJob(Compilation &C,
   case llvm::Triple::hexagon:
 AddHexagonTargetArgs(Args, CmdArgs);
 break;
+
+  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm64:
+AddWebAssemblyTargetArgs(Args, CmdArgs);
+break;
   }
 
   // The 'g' groups options involve a somewhat intricate sequence of decisions

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=257006&r1=257005&r2=257006&view=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Wed Jan  6 19:00:21 2016
@@ -82,6 +82,8 @@ private:
 llvm::opt::ArgStringList &CmdArgs) const;
   void AddHexagonTargetArgs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const;
+  void AddWebAssemblyTargetArgs(const llvm::opt::ArgList &Args,
+llvm::opt::ArgStringList &CmdArgs) const;
 
   enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
 

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257006&r1=257005&r2=257006&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan  6 19:00:21 2016
@@ -1,7 +1,9 @@
-// A basic clang -cc1 command-line.
+// A basic clang -cc1 command-line. WebAssembly is somewhat special in
+// enabling -ffunction-sections, -fdata-sections, and -fvisibility=hidden by
+// default.
 
 // RUN: %clang %s -### -target wasm32-unknown-unknown 2>&1 | FileCheck 
-check-prefix=CC1 %s
-// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-ffunction-sections" "-fdata-sections"
+// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} 
"-fvisibility" "hidden" {{.*}} "-ffunction-sections" "-fdata-sections"
 
 // Ditto, but ensure that a user -fno-function-sections disables the
 // default -ffunction-sections.
@@ -21,7 +23,8 @@
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: lld{{.*}}" "-flavor" "ld" "[[temp]]" "-o" "a.out"
 
-// A basic C link command-line with optimization.
+// A basic C link command-line with optimization. WebAssembly is somewhat
+// special in enabling --gc-sections by default.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
%s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"

Modified: cfe/trunk/test/Driver/wasm32-unknown-unknown.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm32-unknown-unknown.cpp?rev=257006&r1=257005&r2=257006&view=diff
==
--- cfe/trunk/test/Driver/wasm32-unknown-unknown.cpp (original)
+++ cfe/trunk/test/Driver/wasm32-unknown-unknown.cpp Wed Jan  6 19:00:21 2016
@@ -13,34 +13,34 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
 
 extern "C" {
 
-// CHECK: @align_c = global i32 1
+// CHECK: @align_c = hidden global i32 1
 int align_c = __alignof(char);
 
-// CHECK: @align_s = global i32 2
+// CHECK: @align_s = hidden global i32 2
 int align_s = __alignof(short);
 
-// CHECK: @align_i = global i32 4
+// CHECK: @align_i = hidden global i32 4
 int align_i = __

Re: [PATCH] D9600: Add scan-build python implementation

2016-01-06 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Hi Laszlo,

I've run scan-build-py with both environment-variable-based and library-based 
interposition on our open source benchmark suite and it looks like it is in 
great shape on Darwin! There are still some remaining issues with xcodebuild, 
but I will help fix these after scan-build-py is committed.

Please apply for commit access (the instructions are at 
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access), update the 
commit message, and commit.

Thanks for all your hard work on this!



Comment at: tools/scan-build-py/libscanbuild/intercept.py:261
@@ +260,3 @@
+
+Same problem on linux when SELinux is enabled. The status query program
+'sestatus' and the output when it's enabled 'SELinux status: enabled'. """

Great! Thanks for checking for this.


Comment at: tools/scan-build-py/libscanbuild/runner.py:42
@@ +41,3 @@
+
+@require(['command', 'directory', 'file',  # an entry from compilation database
+  'clang', 'direct_args',  # compiler name, and arguments from command

Thanks for documenting these.


http://reviews.llvm.org/D9600



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


r257007 - [WebAssembly] Add a test to ensure that -fvisibility=default works.

2016-01-06 Thread Dan Gohman via cfe-commits
Author: djg
Date: Wed Jan  6 19:15:05 2016
New Revision: 257007

URL: http://llvm.org/viewvc/llvm-project?rev=257007&view=rev
Log:
[WebAssembly] Add a test to ensure that -fvisibility=default works.

It should override the default of -fvisibility=hidden.

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=257007&r1=257006&r2=257007&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Wed Jan  6 19:15:05 2016
@@ -17,6 +17,12 @@
 // RUN: %clang %s -### -target wasm32-unknown-unknown -fno-data-sections 2>&1 
| FileCheck -check-prefix=NO_DATA_SECTIONS %s
 // NO_DATA_SECTIONS-NOT: data-sections
 
+// Ditto, but ensure that a user -fvisibility=default disables the default
+// -fvisibilt=hidden.
+
+// RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 
2>&1 | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s
+// FVISIBILITY_DEFAULT-NOT: hidden
+
 // A basic C link command-line.
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown %s 
2>&1 | FileCheck -check-prefix=LINK %s


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


r257008 - Improve documentation comments for IdentifierNamespace values.

2016-01-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  6 19:17:43 2016
New Revision: 257008

URL: http://llvm.org/viewvc/llvm-project?rev=257008&view=rev
Log:
Improve documentation comments for IdentifierNamespace values.

Modified:
cfe/trunk/include/clang/AST/DeclBase.h

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=257008&r1=257007&r2=257008&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Jan  6 19:17:43 2016
@@ -113,6 +113,9 @@ public:
 /// Tags, declared with 'struct foo;' and referenced with
 /// 'struct foo'.  All tags are also types.  This is what
 /// elaborated-type-specifiers look for in C.
+/// This also contains names that conflict with tags in the
+/// same scope but that are otherwise ordinary names (non-type
+/// template parameters and indirect field declarations).
 IDNS_Tag = 0x0002,
 
 /// Types, declared with 'struct foo', typedefs, etc.
@@ -131,7 +134,7 @@ public:
 IDNS_Namespace   = 0x0010,
 
 /// Ordinary names.  In C, everything that's not a label, tag,
-/// or member ends up here.
+/// member, or function-local extern ends up here.
 IDNS_Ordinary= 0x0020,
 
 /// Objective C \@protocol.
@@ -160,7 +163,9 @@ public:
 
 /// This declaration is a function-local extern declaration of a
 /// variable or function. This may also be IDNS_Ordinary if it
-/// has been declared outside any function.
+/// has been declared outside any function. These act mostly like
+/// invisible friend declarations, but are also visible to unqualified
+/// lookup within the scope of the declaring function.
 IDNS_LocalExtern = 0x0800
   };
 


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


r257009 - Test that we're not forwarding on -g options to the non integrated assembler.

2016-01-06 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Wed Jan  6 19:23:12 2016
New Revision: 257009

URL: http://llvm.org/viewvc/llvm-project?rev=257009&view=rev
Log:
Test that we're not forwarding on -g options to the non integrated assembler.

This is adding a test for an old fixed PR to make sure we don't regress.

Modified:
cfe/trunk/test/Driver/gcc_forward.c

Modified: cfe/trunk/test/Driver/gcc_forward.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gcc_forward.c?rev=257009&r1=257008&r2=257009&view=diff
==
--- cfe/trunk/test/Driver/gcc_forward.c (original)
+++ cfe/trunk/test/Driver/gcc_forward.c Wed Jan  6 19:23:12 2016
@@ -27,3 +27,9 @@
 // CHECK-NOT: "-Wall"
 // CHECK-NOT: "-Wdocumentation"
 // CHECK: "-o" "a.out"
+
+// Check that we're not forwarding -g options to the assembler
+// RUN: %clang -g -target x86_64-unknown-linux-gnu -no-integrated-as -c %s 
-### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+// CHECK-ASM: as
+// CHECK-ASM-NOT: "-g"


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


  1   2   >