r248659 - Remove move constructor and assignment operator from SourceMappingRegion. The types of the fields are trivially copyable. NFC

2015-09-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Sep 26 00:10:16 2015
New Revision: 248659

URL: http://llvm.org/viewvc/llvm-project?rev=248659=rev
Log:
Remove move constructor and assignment operator from SourceMappingRegion. The 
types of the fields are trivially copyable. NFC

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=248659=248658=248659=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Sat Sep 26 00:10:16 2015
@@ -47,17 +47,6 @@ public:
   Optional LocEnd)
   : Count(Count), LocStart(LocStart), LocEnd(LocEnd) {}
 
-  SourceMappingRegion(SourceMappingRegion &)
-  : Count(std::move(Region.Count)), LocStart(std::move(Region.LocStart)),
-LocEnd(std::move(Region.LocEnd)) {}
-
-  SourceMappingRegion =(SourceMappingRegion &) {
-Count = std::move(RHS.Count);
-LocStart = std::move(RHS.LocStart);
-LocEnd = std::move(RHS.LocEnd);
-return *this;
-  }
-
   const Counter () const { return Count; }
 
   void setCounter(Counter C) { Count = C; }
@@ -426,7 +415,7 @@ struct CounterCoverageMappingBuilder
   MostRecentLocation = getIncludeOrExpansionLoc(EndLoc);
 
 assert(SM.isWrittenInSameFile(Region.getStartLoc(), EndLoc));
-SourceRegions.push_back(std::move(Region));
+SourceRegions.push_back(Region);
   }
   RegionStack.pop_back();
 }


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


r248660 - Use None to avoid re-mentioning the ArrayRef type to call the default constructor.

2015-09-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Sep 26 00:22:17 2015
New Revision: 248660

URL: http://llvm.org/viewvc/llvm-project?rev=248660=rev
Log:
Use None to avoid re-mentioning the ArrayRef type to call the default 
constructor.

Modified:
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h?rev=248660=248659=248660=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Sat Sep 26 
00:22:17 2015
@@ -1479,7 +1479,7 @@ public:
 
   /// Return an empty list.
   ArrayRef successors() {
-return ArrayRef();
+return None;
   }
 
   SExpr *returnValue() { return Retval; }
@@ -1507,7 +1507,7 @@ inline ArrayRef Terminator:
 case COP_Branch: return cast(this)->successors();
 case COP_Return: return cast(this)->successors();
 default:
-  return ArrayRef();
+  return None;
   }
 }
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=248660=248659=248660=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Sep 26 00:22:17 2015
@@ -6737,7 +6737,7 @@ public:
 Sema , ActiveTemplateInstantiation::InstantiationKind Kind,
 SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
 Decl *Entity, NamedDecl *Template = nullptr,
-ArrayRef TemplateArgs = ArrayRef(),
+ArrayRef TemplateArgs = None,
 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
 
 InstantiatingTemplate(const InstantiatingTemplate&) = delete;

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=248660=248659=248660=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sat Sep 26 00:22:17 2015
@@ -1307,7 +1307,7 @@ Optional Type::getOb
   if (!curClassDecl) {
 // If we don't have a context type (e.g., this is "id" or some
 // variant thereof), substitute the bounds.
-return llvm::ArrayRef();
+return None;
   }
 
   // Follow the superclass chain until we've mapped the receiver type
@@ -1327,7 +1327,7 @@ Optional Type::getOb
   // If we don't have a receiver type, or the receiver type does not
   // have type arguments, substitute in the defaults.
   if (!objectType || objectType->isUnspecialized()) {
-return llvm::ArrayRef();
+return None;
   }
 
   // The receiver type has the type arguments we want.


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


Re: [PATCH] D12358: [Analyzer] Handling constant bound loops

2015-09-25 Thread Sean Eveson via cfe-commits
seaneveson added a comment.

My initial approach was for the analyzer to have as much information as 
possible after the loop. This means there are cases where the information is 
incorrect. Future work would be to reduce these cases.

I believe your preferred approach is to have no inaccuracies after the loop, 
which can initially be achieved by providing less information. Further work 
would add more (guaranteed accurate) information. In this way the analyzer is 
naturally conservative when it isn't sure of something. I now agree that this 
is a better approach to take.

What do people think about me creating a new patch based on your feedback? The 
aim would be to widen any non-exiting loops by invalidation. The initial patch 
would be behind a flag and would use the TK_EntireMemSpace trait to 
conservatively invalidate 'everything' when a loop does not exit. It would then 
run through the loop body in the invalidated state, resulting in the analysis 
of all possible paths. The loop would then exit from the (now possibly false) 
loop condition, or a (now reachable) break statement. Loops that never exit 
regardless of any variables would be an exception; see my comment below for 
thoughts on handling infinite loops.

Future improvements would prevent unnecessary invalidation and calculate the 
values of modified variables (after the loop).



Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:10
@@ +9,3 @@
+///
+/// This file contains functions which are used to widen constant bound loops.
+/// A loop may be widened to approximate the exit state(s), without analysing

zaks.anna wrote:
> This would allow to widen not just the constant bound loops!
> I think we should widen any loop that we know we did not fully execute.
I agree that the goal should be to widen any loop that isn't fully executed, 
but we need to consider infinite loops, which might be falsely exited after 
widening. The way I see it, assuming the widening will be done by invalidating 
variables/memory, we could either:

  # Only widen loops which definitely exit.
  # Widen all loops unless they are definitely infinite (or widen them in a way 
which minimizes the number of infinite loops which then exit).
  # Come up with a method which decides if a loops is infinite or not (but 
tolerate mistakes either way) and widen when we "think" the loop will exit. 
This is similar to the current approach for constant bound loops.

My current preference would be option 2. This is based on the assumption that 
loops are generally written to exit at some point, and if they aren't, they are 
unlikely to have code after them anyway. When it does not know which branch the 
program will go down, the analyzer's approach is to go down both. Similarly if 
the analyzer does not know whether the loop exits, it should optimistically go 
down the exit branch (IMO).


Comment at: test/Analysis/constant-bound-loops.c:174
@@ +173,3 @@
+
+clang_analyzer_eval(g_global); // expected-warning {{UNKNOWN}}
+clang_analyzer_eval(s_arg); // expected-warning {{UNKNOWN}}

zaks.anna wrote:
> seaneveson wrote:
> > zaks.anna wrote:
> > > I think we should extend this test case.
> > > Ex: what about heap, what about variables touched by the loop variables 
> > > declared in the loop's scope?
> > Good point. I actually encountered a false positive while improving this 
> > case.
> > 
> > 
> > ```
> > int *h_ptr = malloc(sizeof(int));
> > *h_ptr = 3;
> > for (int i = 0; i < 10; ++i) {} // WARNING: Potential leak of memory 
> > pointed to by 'h_ptr'
> > ```
> > 
> > The value of h_ptr is invalidated, but I'm not sure about *h_ptr. Is it 
> > likely this warning is produced because the pointer is invalidated, but not 
> > the memory?
> Could you provide the full example? There is leak in the code segment above. 
Sorry, I meant to say the warning is there regardless of what comes after the 
loop. Here is a full test case:
```
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);

void test() {
int *h_ptr = (int *) malloc(sizeof(int));
for (int i = 0; i < 2; ++i) {} // No warning.
for (int i = 0; i < 10; ++i) {}
free(h_ptr);
}
```
It produces the following for me:
```
clang.exe -cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config 
widen-constant-bound-loops=true test.cpp
test.cpp:8:31: warning: Potential leak of memory pointed to by 'h_ptr'
for (int i = 0; i < 10; ++i) {}
  ^
1 warning generated.
```


http://reviews.llvm.org/D12358



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


r248578 - Revert "This patch adds missing pieces to clang, including the PS4 toolchain definition, added warnings, PS4 defaults, and Driver changes needed for our compiler."

2015-09-25 Thread Greg Bedwell via cfe-commits
Author: gbedwell
Date: Fri Sep 25 11:11:00 2015
New Revision: 248578

URL: http://llvm.org/viewvc/llvm-project?rev=248578=rev
Log:
Revert "This patch adds missing pieces to clang, including the PS4 toolchain 
definition, added warnings, PS4 defaults, and Driver changes needed for our 
compiler."

This reverts commit r248546 to get our bot green again while we discuss the 
best way forward.

Removed:
cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include/.keep
cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep
cfe/trunk/test/Driver/ps4-header-search.c
cfe/trunk/test/Driver/ps4-linker-non-win.c
cfe/trunk/test/Driver/ps4-pic.c
cfe/trunk/test/Driver/ps4-sdk-root.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/test/Driver/debug-options.c
cfe/trunk/test/Driver/rtti-options.cpp
cfe/trunk/test/Driver/stack-protector.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=248578=248577=248578=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Sep 25 11:11:00 
2015
@@ -192,18 +192,4 @@ def warn_target_unsupported_nan2008 : Wa
 def warn_target_unsupported_nanlegacy : Warning<
   "ignoring '-mnan=legacy' option because the '%0' architecture does not 
support it">,
   InGroup;
-
-def warn_drv_unable_to_find_directory_expected : Warning<
-  "unable to find %0 directory, expected to be in '%1'">,
-  InGroup;
-
-def warn_drv_ps4_force_pic : Warning<
-  "option '%0' was ignored by the PS4 toolchain, using '-fPIC'">,
-  InGroup;
-
-def warn_drv_ps4_sdk_dir : Warning<
-  "environment variable SCE_PS4_SDK_DIR is set, but points to invalid or 
nonexistent directory '%0'">,
-  InGroup;
-
-def err_drv_unsupported_linker : Error<"unsupported value '%0' for -linker 
option">;
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=248578=248577=248578=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Sep 25 11:11:00 2015
@@ -820,7 +820,3 @@ def CudaCompat : DiagGroup<"cuda-compat"
 
 // A warning group for things that will change semantics in the future.
 def FutureCompat : DiagGroup<"future-compat">;
-
-def InvalidOrNonExistentDirectory : 
DiagGroup<"invalid-or-nonexistent-directory">;
-
-def OptionIgnored : DiagGroup<"option-ignored">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=248578=248577=248578=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Sep 25 11:11:00 2015
@@ -2254,9 +2254,6 @@ const ToolChain ::getToolChain(co
 case llvm::Triple::CUDA:
   TC = new toolchains::CudaToolChain(*this, Target, Args);
   break;
-case llvm::Triple::PS4:
-  TC = new toolchains::PS4CPU(*this, Target, Args);
-  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=248578=248577=248578=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Sep 25 11:11:00 2015
@@ -4065,69 +4065,3 @@ void WebAssembly::addClangTargetOptions(
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 }
-
-PS4CPU::PS4CPU(const Driver , const llvm::Triple , const ArgList 
)
-: Generic_ELF(D, Triple, Args) {
-  if (Args.hasArg(options::OPT_static))
-D.Diag(diag::err_drv_unsupported_opt_for_target) << "-static" << "PS4";
-
-  // Determine where to find the PS4 libraries. We use SCE_PS4_SDK_DIR
-  // if it exists; otherwise use the driver's installation path, which
-  // should be /host_tools/bin.
-  const char *EnvValue = getenv("SCE_PS4_SDK_DIR");
-  if (EnvValue && !llvm::sys::fs::exists(EnvValue))
-getDriver().Diag(clang::diag::warn_drv_ps4_sdk_dir) << EnvValue;
-
-  std::string PS4SDKDir = (EnvValue ? EnvValue : getDriver().Dir + 

Re: [PATCH] D11279: Initial patch for PS4 toolchain

2015-09-25 Thread NAKAMURA Takumi via cfe-commits
chapuni added a subscriber: chapuni.
chapuni added a comment.

Would this cause bunch of failures if target is *-ps4 and SDK_DIR is empty?

  clang-3.8: error: unable to find PS4 system headers directory, expected to be 
in 
'/home/buildbot/Buildbot/Slave/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm.obj/bin/../../target/include'


Repository:
  rL LLVM

http://reviews.llvm.org/D11279



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


[PATCH] D13166: Create modernize-make-unique check.

2015-09-25 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: alexfh.
angelgarcia added subscribers: klimek, cfe-commits.

create a check that replaces 'std::unique_ptr(new type(args...))' with 
'std::make_unique(args...)'. It was on the list of "Ideas for new Tools". 
It needs to be tested more carefully, but first I wanted to know if you think 
it is worth the effort.

http://reviews.llvm.org/D13166

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -0,0 +1,92 @@
+// RUN: %python %S/check_clang_tidy.py %s modernize-make-unique %t
+
+namespace std {
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(type *ptr);
+  unique_ptr(const unique_ptr ) = delete;
+  unique_ptr(unique_ptr &);
+  ~unique_ptr();
+  type *() { return *ptr; }
+  type *operator->() { return ptr; }
+  type *release();
+  void reset();
+  void reset(type *pt);
+
+private:
+  type *ptr;
+};
+
+}
+
+struct Base {
+  Base();
+  Base(int, int);
+};
+
+struct Derived : public Base {
+  Derived();
+  Derived(int, int);
+};
+
+struct Pair {
+  int a, b;
+};
+
+int g(std::unique_ptr P);
+
+std::unique_ptr getPointer() {
+  return std::unique_ptr(new Base);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
+  // CHECK-FIXES: return std::make_unique();
+}
+
+void f() {
+  std::unique_ptr P1 = std::unique_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P1 = std::make_unique();
+
+  // Without parenthesis
+  std::unique_ptr P2 = std::unique_ptr(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P2 = std::make_unique();
+
+  // With auto.
+  auto P3 = std::unique_ptr(new int());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+  // CHECK-FIXES: auto P3 = std::make_unique();
+
+  {
+// No std.
+using namespace std;
+unique_ptr Q = unique_ptr(new int());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_unique instead
+// CHECK-FIXES: unique_ptr Q = std::make_unique();
+  }
+
+  std::unique_ptr R(new int());
+
+  // Create the unique_ptr as a parameter to a function.
+  int T = g(std::unique_ptr(new int()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+  // CHECK-FIXES: int T = g(std::make_unique());
+
+  // Arguments are correctly handled.
+  std::unique_ptr Pbase = std::unique_ptr(new Base(5, T));
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr Pbase = std::make_unique(5, T);
+
+  // Works with init lists.
+  std::unique_ptr Ppair = std::unique_ptr(new Pair{T, 1});
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead
+  // CHECK-FIXES: std::unique_ptr Ppair = std::make_unique({T, 1});
+
+  // Only replace if the type in the template is the same than the type returned
+  // by the new operator.
+  auto Pderived = std::unique_ptr(new Derived());
+
+  // The pointer is returned by the function, nothing to do.
+  std::unique_ptr RetPtr = getPointer();
+}
Index: clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "LoopConvertCheck.h"
+#include "MakeUniqueCheck.h"
 #include "PassByValueCheck.h"
 #include "ReplaceAutoPtrCheck.h"
 #include "ShrinkToFitCheck.h"
@@ -28,6 +29,8 @@
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
 CheckFactories.registerCheck("modernize-loop-convert");
+CheckFactories.registerCheck(
+"modernize-make-unique");
 CheckFactories.registerCheck("modernize-pass-by-value");
 CheckFactories.registerCheck(
 "modernize-replace-auto-ptr");
Index: clang-tidy/modernize/MakeUniqueCheck.h
===
--- /dev/null
+++ clang-tidy/modernize/MakeUniqueCheck.h
@@ -0,0 +1,41 @@
+//===--- MakeUniqueCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H
+#define 

Re: [PATCH] D13166: Create modernize-make-unique check.

2015-09-25 Thread Manuel Klimek via cfe-commits
klimek added a comment.

This is definitely a useful check to have in modernize.



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:25-27
@@ +24,5 @@
+
+/// \brief Returns the length of the token that goes since the beggining of the
+/// constructor call until the '<' of the template. This token should either be
+/// 'unique_ptr' or 'std::unique_ptr'. In any other case, it returns 0.
+static int getTokenLength(SourceLocation TokenStart, const SourceManager ,

How can that ever return 0 if you have matchesName("::std::unique_ptr") below?


Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:51
@@ +50,3 @@
+cxxConstructExpr(
+hasType(hasCanonicalType(
+hasDeclaration(classTemplateSpecializationDecl(

Why do we need the hasCanonicalType?


http://reviews.llvm.org/D13166



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


Re: [PATCH] D13081: [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck

2015-09-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Awesome! This makes the check far more usable.

See a few minor comments in-line.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:140
@@ +139,3 @@
+  Finder->addMatcher(
+  namedDecl(unless(isExpansionInSystemHeader())).bind("decl"), this);
+  Finder->addMatcher(

ClangTidy takes care of filtering errors. It doesn't show errors in system 
headers by default, but there's an option to show them, if needed (e.g. for 
library developers). Is there any reason to add filtering here as well?


Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:537
@@ +536,3 @@
+
+return addUsage(NamingCheckFailures, Decl->getParent(),
+Decl->getNameInfo().getSourceRange(), 
Result.SourceManager);

Please split `return` and `addUsage` here and in other places. It looks rather 
confusing to me and adds no benefits.


Comment at: test/clang-tidy/readability-identifier-naming.cpp:69
@@ -72,1 +68,3 @@
 
+#include 
+// Expect NO warnings or errors from system headers, it shouldn't even be 
checked

Please don't #include system headers to tests. There are multiple reasons to 
avoid this:
  * that won't work in some test configurations;
  * we don't control the contents of system headers, so we can't make tests 
reliable;
  * testing time can increase significantly due to the possibly large size of 
system headers.

If you need to test includes, put mock headers to 
test/clang-tidy/Inputs// and specify this directory in the 
clang-tidy invocation:

  // RUN: %python %S/check_clang_tidy.py %s readability-identifier-naming %t \
  // RUN:   -config=... \
  // RUN:   -- -std=...  -isystem=%S/Inputs/readability-identifier-naming 


http://reviews.llvm.org/D13081



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


Re: [PATCH] D12793: Three new security overflow builtins with generic argument types

2015-09-25 Thread John McCall via cfe-commits
rjmccall added a comment.

X and Y aren't unreasonable for the operands, although you could also use 
"left" and "right" (or LHS/RHS), especially since it's significant for 
subtraction.  R is short for "result" and should be spelled out.  E is 
presumably short for "encompassing", but that is not immediately obvious even 
to someone reading your patch; spelling it out wouldn't hurt, or you could at 
least use a longer abbreviation.

You should also spell out the different *Ty suffixes in some way that 
differentiates them.  I don't think you actually need the *QTy variables.  The 
*ITy variables aren't really types and should not be named that way.  *LLVMTy 
is not unreasonable for the IR types.


http://reviews.llvm.org/D12793



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


Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-25 Thread Eli Bendersky via cfe-commits
eliben accepted this revision.
eliben added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D13171



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


Re: [PATCH] D13079: [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck

2015-09-25 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a few comments.

Please tell me, if you need me to commit the patch for you after you address 
the comments.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:574
@@ -578,2 +573,3 @@
 Diag << FixItHint::CreateReplacement(
-CharSourceRange::getTokenRange(Range), Failure.Fixup);
+SourceRange(SourceLocation::getFromRawEncoding(Loc)),
+Failure.Fixup);

This change assumes that the name is always represented by a single token. 
Please add a comment explaining why this can be done.


Comment at: clang-tidy/readability/IdentifierNamingCheck.h:65
@@ -64,7 +64,3 @@
 
-private:
-  std::vector NamingStyles;
-  bool IgnoreFailedSplit;
-
   struct NamingCheckFailure {
 std::string KindName;

Please add a comment for this struct. Especially for the `RawUsageLocs` field.


Comment at: clang-tidy/readability/IdentifierNamingCheck.h:73
@@ -76,2 +72,3 @@
   };
+  typedef llvm::DenseMap 
NamingCheckFailureMap;
 

80 character limit.


http://reviews.llvm.org/D13079



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


r248595 - Make incomplete type errors better with enable_if

2015-09-25 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Fri Sep 25 12:53:16 2015
New Revision: 248595

URL: http://llvm.org/viewvc/llvm-project?rev=248595=rev
Log:
Make incomplete type errors better with enable_if

This patch fixes the order in which we evaluate the different ways that
a function call could be disallowed. Now, if you call a non-overloaded
function with an incomplete type and failing enable_if, we'll prioritize
reporting the more obvious error (use of incomplete type) over reporting
the failing enable_if.

Thanks to Ettore Speziale for the patch!


Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=248595=248594=248595=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Sep 25 12:53:16 2015
@@ -11664,16 +11664,6 @@ Sema::BuildCallToMemberFunction(Scope *S
 FoundDecl = MemExpr->getFoundDecl();
 Qualifier = MemExpr->getQualifier();
 UnbridgedCasts.restore();
-
-if (const EnableIfAttr *Attr = CheckEnableIf(Method, Args, true)) {
-  Diag(MemExprE->getLocStart(),
-   diag::err_ovl_no_viable_member_function_in_call)
-  << Method << Method->getSourceRange();
-  Diag(Method->getLocation(),
-   diag::note_ovl_candidate_disabled_by_enable_if_attr)
-  << Attr->getCond()->getSourceRange() << Attr->getMessage();
-  return ExprError();
-}
   } else {
 UnresolvedMemberExpr *UnresExpr = cast(NakedMemExpr);
 Qualifier = UnresExpr->getQualifier();
@@ -11837,6 +11827,21 @@ Sema::BuildCallToMemberFunction(Scope *S
   if (CheckFunctionCall(Method, TheCall, Proto))
 return ExprError();
 
+  // In the case the method to call was not selected by the overloading
+  // resolution process, we still need to handle the enable_if attribute. Do
+  // that here, so it will not hide previous -- and more relevant -- errors
+  if (isa(NakedMemExpr)) {
+if (const EnableIfAttr *Attr = CheckEnableIf(Method, Args, true)) {
+  Diag(MemExprE->getLocStart(),
+   diag::err_ovl_no_viable_member_function_in_call)
+  << Method << Method->getSourceRange();
+  Diag(Method->getLocation(),
+   diag::note_ovl_candidate_disabled_by_enable_if_attr)
+  << Attr->getCond()->getSourceRange() << Attr->getMessage();
+  return ExprError();
+}
+  }
+
   if ((isa(CurContext) || 
isa(CurContext)) && 
   TheCall->getMethodDecl()->isPure()) {

Modified: cfe/trunk/test/SemaCXX/enable_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=248595=248594=248595=diff
==
--- cfe/trunk/test/SemaCXX/enable_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/enable_if.cpp Fri Sep 25 12:53:16 2015
@@ -2,6 +2,8 @@
 
 typedef int (*fp)(int);
 int surrogate(int);
+struct Incomplete;  // expected-note{{forward declaration of 'Incomplete'}} \
+// expected-note {{forward declaration of 'Incomplete'}}
 
 struct X {
   X() = default;  // expected-note{{candidate constructor not viable: requires 
0 arguments, but 1 was provided}}
@@ -13,13 +15,16 @@ struct X {
 
   void g(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))); 
 // expected-note{{candidate disabled: chosen when 'n' is zero}}
 
-  void h(int n, int m = 0) __attribute((enable_if(m == 0, "chosen when 'm' is 
zero")));  // expected-note{{candidate disabled: chosen when 'm' is zero}}
+  void h(int n, int m = 0) __attribute__((enable_if(m == 0, "chosen when 'm' 
is zero")));  // expected-note{{candidate disabled: chosen when 'm' is zero}}
 
   static void s(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is 
zero")));  // expected-note2{{candidate disabled: chosen when 'n' is zero}}
 
   void conflict(int n) __attribute__((enable_if(n+n == 10, "chosen when 'n' is 
five")));  // expected-note{{candidate function}}
   void conflict(int n) __attribute__((enable_if(n*2 == 10, "chosen when 'n' is 
five")));  // expected-note{{candidate function}}
 
+  void hidden_by_argument_conversion(Incomplete n, int m = 0) 
__attribute__((enable_if(m == 10, "chosen when 'm' is ten")));
+  Incomplete hidden_by_incomplete_return_value(int n = 0) 
__attribute__((enable_if(n == 10, "chosen when 'n' is ten"))); // 
expected-note{{'hidden_by_incomplete_return_value' declared here}}
+
   operator long() __attribute__((enable_if(true, "chosen on your platform")));
   operator int() __attribute__((enable_if(false, "chosen on other platform")));
 
@@ -85,6 +90,9 @@ void test() {
 
   x.conflict(5);  // expected-error{{call to member function 'conflict' is 
ambiguous}}
 
+  x.hidden_by_argument_conversion(10);  // expected-error{{argument type 
'Incomplete' is incomplete}}
+  

r248596 - Fix bug on reporting availability of deleted methods in libclang.

2015-09-25 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Fri Sep 25 12:53:16 2015
New Revision: 248596

URL: http://llvm.org/viewvc/llvm-project?rev=248596=rev
Log:
Fix bug on reporting availability of deleted methods in libclang.

Patch by Sergey Kalinichev.

Added:
cfe/trunk/test/Index/availability.cpp
Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Added: cfe/trunk/test/Index/availability.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/availability.cpp?rev=248596=auto
==
--- cfe/trunk/test/Index/availability.cpp (added)
+++ cfe/trunk/test/Index/availability.cpp Fri Sep 25 12:53:16 2015
@@ -0,0 +1,13 @@
+void foo() = delete;
+
+struct Foo {
+  int foo() = delete;
+  Foo() = delete;
+};
+
+
+// RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s
+// CHECK: FunctionDecl=foo:1:6 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
+// CHECK: StructDecl=Foo:3:8 (Definition) [type=Foo] [typekind=Record] 
[isPOD=1]
+// CHECK: CXXMethod=foo:4:7 (unavailable) [type=int ()] 
[typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
+// CHECK: CXXConstructor=Foo:5:3 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=248596=248595=248596=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Sep 25 12:53:16 2015
@@ -6412,7 +6412,7 @@ extern "C" {
 
 static CXAvailabilityKind getCursorAvailabilityForDecl(const Decl *D) {
   if (isa(D) && cast(D)->isDeleted())
-return CXAvailability_Available;
+return CXAvailability_NotAvailable;
   
   switch (D->getAvailability()) {
   case AR_Available:


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


Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-25 Thread Eli Bendersky via cfe-commits
eliben added inline comments.


Comment at: lib/Headers/clang_cuda_support.h:53
@@ +52,3 @@
+// WARNING: Preprocessor hacks below are based on specific of
+// implementation of CUDA-7.0 headers and are expected to break with
+// any other version of CUDA headers.

If this includes CUDA headers, maybe you can #error out if the CUDA version 
isn't good?


http://reviews.llvm.org/D13171



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


Re: [PATCH] D13157: Teach -Wtautological-overlap-compare about enums

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

Thanks, I think this looks good (pending confirmation from Richard).

~Aaron


http://reviews.llvm.org/D13157



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


Re: [PATCH] D12774: createUniqueFile() is documented to create the file in the temporary directory unless it's supplied an absolute path.Make sure the output filepath supplied to createUniqueFile() in

2015-09-25 Thread Cameron Esfahani via cfe-commits
dirty added a comment.

Should I go ahead and commit this change?


http://reviews.llvm.org/D12774



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


Re: [PATCH] Change memcpy/memmove/memset to have dest and source alignment

2015-09-25 Thread Hal Finkel via cfe-commits
Hi Pete,

Thanks for working on this.

+  class IntegerAlignment {
+  private:
+uint64_t Align;

You explain in the patch summary why this is here, but please add a comment 
with the explanation as well.

Regarding the auto-upgrade, are we going to run into problems if we separate 
our the 'volatile' tag for the source and the destination as Lang had 
suggested? If we're going to do that, should we do it all at the same time? 
Does it change the need for the IntegerAlignment class?

Everything else looks good, and I like the cleanup in AlignmentFromAssumptions 
:-)

Thanks again,
Hal

P.S. I find full-context patches in Phabricator much easier than diffs; this 
does not matter for the automated regression-test updates, but for the code 
changes, I appreciate patches there.

- Original Message -
> From: "Pete Cooper" 
> To: "Hal J. Finkel" 
> Cc: "Lang Hames" , "LLVM Commits" 
> , cfe-commits@lists.llvm.org
> Sent: Friday, August 28, 2015 5:59:18 PM
> Subject: [PATCH] Change memcpy/memmove/memset to have dest and source 
> alignment
> 
> 
> 
> Hi Hal/Lang
> 
> This came out of a discussion here:
> http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html
> 
> We want to be able to provide alignment for both the source and dest
> of mem intrinsics, instead of the alignment argument which only
> provides the minimum of dest/src.
> 
> Instead of adding another argument, I removed the alignment argument
> and added the align attributes to the src/dest pointer arguments.
> 
> I’ve updated the MemIntrinsic definition to handle this, and all of
> the code to now call getDestAlignment/getSrcAlignment instead of
> getAlignment. For the few places where it wasn’t clear whether
> dest/src was the right choice, i’ve left a FIXME and I take the
> minimum of dest/src so as to match the current behavior.
> 
> I’ve also updated the create methods in the IR builder. There is a
> (temporary) class there to handle the new source alignment
> parameter, as otherwise existing callers of this code could end up
> having the isVolatile bool implicitly converted to the source
> alignment. I’ll remove this once out-of-tree users have had a chance
> to update to this patch.
> 
> Tests were updated to automatically strip out the alignment argument
> (the regex find/replace is in the patch). I then ran make check and
> explicitly added back in alignments to all tests which needed it. I
> tried to automatically update tests to transfer alignment to the
> attributes, but that wasn’t feasible due to constant expressions
> confusing regex (turns out regex doesn’t like recursion, which is
> more or less what you need to get balanced braces in gep(bit
> cast(inttoptr())) type expressions which we have in our tests).
> 
> There’s also a commit which shows how auto upgrading bitcode is
> handled. There was already a test for llvm 3.2 which called memcpy
> so is used for this. I’ll add tests to upgrade memmove and memset
> prior to committing but just wanted to get the review process
> started. memmove/memset tests will be almost identical to the memcpy
> test we already have. I will use 3.7 as the bitcode generator for
> those tests though.
> 
> Finally, for LLVM, i’ve got a patch to show a cleanup of
> AlignmentFromAssumptions now that dest and source alignments can be
> different. This is the only patch which can be committed on its own,
> and after the rest. Everything else here is broken out in to
> separate commits just to try ease the review process.
> 
> For clang, the majority of changes are to pass both source and dest
> alignments to the IR Builder. Again I tried to get the right ones
> where I could, but if I didn’t know the code well enough I just pass
> the same value to dest/src to match the current behaviour. clang
> tests were all updated by hand because they all needed to check for
> the alignment attribute being set correctly coming out of codegen.
> 
> Finally, this is really just the minimum changes needed to get this
> in tree. I haven’t made any effort to teach LLVM codegen about this.
> That can luckily be done later, and probably independently for most
> backends by their respective owners.
> 
> Apologies for the scale of this patch. As you can imagine, there
> wasn’t really a nice way to land this without excessive churn of the
> test cases themselves.
> 
> Cheers,
> Pete
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-25 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 35760.
tra added a comment.

Include cuda.h and #error if we see wrong CUDA_VERSION.


http://reviews.llvm.org/D13171

Files:
  lib/Headers/CMakeLists.txt
  lib/Headers/clang_cuda_support.h

Index: lib/Headers/clang_cuda_support.h
===
--- /dev/null
+++ lib/Headers/clang_cuda_support.h
@@ -0,0 +1,119 @@
+#ifndef __CLANG_CUDA_SUPPORT_H__
+#define __CLANG_CUDA_SUPPORT_H__
+
+#if defined(__PTX__)
+
+// WARNING: Preprocessor hacks below are based on specific of
+// implementation of CUDA-7.0 headers and are expected to break with
+// any other version of CUDA headers.
+#include "cuda.h"
+#if !defined(CUDA_VERSION)
+#error "cuda.h did not define CUDA_VERSION"
+#elif CUDA_VERSION != 7000
+#error "Unsupported CUDA version!"
+#endif
+
+#define __NVCC__ 1
+#if defined(__CUDA_ARCH__)
+#define __CUDABE__ 1
+#else
+#define __CUDACC__ 1
+#endif
+
+// Fake include guards to prevent inclusion of some CUDA headers.
+#define __HOST_DEFINES_H__
+#define __DEVICE_LAUNCH_PARAMETERS_H__
+#define __TEXTURE_INDIRECT_FUNCTIONS_HPP__
+#define __SURFACE_INDIRECT_FUNCTIONS_HPP__
+
+// Standard CUDA attributes
+#define __constant__ __attribute__((constant))
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __host__ __attribute__((host))
+#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
+#define __shared__ __attribute__((shared))
+
+// Additional macros used throughout CUDA headers.
+#define __align__(x) __attribute__((aligned(x)))
+#define __builtin_align__(x) __align__(x)
+#define __cudart_builtin__
+#define __device_builtin__
+#define __forceinline__ __inline__ __attribute__((always_inline))
+
+#define CUDARTAPI
+#define _CRTIMP
+
+// Texture and surface types are not supported yet.
+#define __device_builtin_surface_type__
+#define __device_builtin_texture_type__
+
+// Include support for built-in variables.
+#include "cuda_builtin_vars.h"
+
+// CUDA headers were implemented with the assumption of split-mode
+// compilation and present CUDA functions differently for host and
+// device mode. Typically in host mode they provide declarations with
+// __device__ attribute attached. In device mode we get definitions
+// but *without* __device__ attribute. This does not work well in
+// combined compilation mode used by clang, so we have to trick CUDA
+// headers into something we can use.
+
+// libdevice functions in device_functions_decls.h either come with
+// __host__ __device__ attributes or with none at all. Temporarily
+// undefine __host__ so only __device__ is applied.
+#pragma push_macro("__CUDACC_RTC__")
+#pragma push_macro("__host__")
+#define __CUDACC_RTC__
+#define __host__
+#include "device_functions_decls.h"
+#pragma pop_macro("__host__")
+#pragma pop_macro("__CUDACC_RTC__")
+
+#include "cuda_runtime.h"
+#include "crt/device_runtime.h"
+
+#if defined(__CUDA_ARCH__)
+// device_functions.hpp and math_functions*.hpp use 'static
+// __forceinline__' (with no __device__) for definitions of device
+// functions. Temporarily redefine __forceinline__ to include
+// __device__.
+#pragma push_macro("__forceinline__")
+#define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+#include "device_functions.h"
+#include "math_functions.h"
+#pragma pop_macro("__forceinline__")
+#else
+#include "device_functions.h"
+#include "math_functions.h"
+#endif
+
+#if defined(__CUDA_ARCH__)
+// Definitions for device specific functions are provided only if
+// __CUDACC__ is defined. Alas, they've already been transitively
+// included by device_functions.h and are now behind include guards.
+// We need to temporarily define __CUDACC__, undo include guards and
+// include the files with implementation of these functions.
+
+#pragma push_macro("__CUDACC__")
+#define __CUDACC__ 1
+
+#undef __DEVICE_ATOMIC_FUNCTIONS_HPP__
+#include "device_atomic_functions.hpp"
+
+#undef __SM_20_ATOMIC_FUNCTIONS_HPP__
+#include "sm_20_atomic_functions.hpp"
+#undef __SM_32_ATOMIC_FUNCTIONS_HPP__
+#include "sm_32_atomic_functions.hpp"
+
+#undef __SM_20_INTRINSICS_HPP__
+#include "sm_20_intrinsics.hpp"
+#undef __SM_30_INTRINSICS_HPP__
+#include "sm_30_intrinsics.hpp"
+#undef __SM_32_INTRINSICS_HPP__
+#include "sm_32_intrinsics.hpp"
+
+#pragma pop_macro("__CUDACC__")
+#endif // __CUDA_ARCH__
+#endif // __PTX__
+#endif // __CLANG_CUDA_SUPPORT_H__
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -17,6 +17,7 @@
   bmiintrin.h
   cpuid.h
   cuda_builtin_vars.h
+  clang_cuda_support.h
   emmintrin.h
   f16cintrin.h
   float.h
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-25 Thread Artem Belevich via cfe-commits
tra marked an inline comment as done.
tra added a comment.

http://reviews.llvm.org/D13171



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


Re: [PATCH] D12982: Move routines for guessing mode/target from driver to ToolChain

2015-09-25 Thread Luke Zarko via cfe-commits
zarko added a comment.

Great!

I don't have commit access; would someone who does please land this?


Repository:
  rL LLVM

http://reviews.llvm.org/D12982



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


Re: [PATCH] D12982: Move routines for guessing mode/target from driver to ToolChain

2015-09-25 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

Oh, sure I can.

Done thusly:

dzur:~/sources/llvm/tools/clang> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
M include/clang/Driver/ToolChain.h
M lib/Driver/ToolChain.cpp
M tools/driver/driver.cpp
Committed r248592

-eric


Repository:
  rL LLVM

http://reviews.llvm.org/D12982



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


[PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-25 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: echristo, eliben, jholewinski.
tra added a subscriber: cfe-commits.

Header files that come with CUDA are assuming split host/device compilation and 
are not usable by clang out of the box.
With a bit of preprocessor magic it's possible to twist them into a form usable 
by clang after D13170 and D13144 land.

http://reviews.llvm.org/D13171

Files:
  lib/Headers/CMakeLists.txt
  lib/Headers/clang_cuda_support.h

Index: lib/Headers/clang_cuda_support.h
===
--- /dev/null
+++ lib/Headers/clang_cuda_support.h
@@ -0,0 +1,119 @@
+#ifndef __CLANG_CUDA_SUPPORT_H__
+#define __CLANG_CUDA_SUPPORT_H__
+
+#if defined(__PTX__)
+
+#define __NVCC__ 1
+#if defined(__CUDA_ARCH__)
+#define __CUDABE__ 1
+#else
+#define __CUDACC__ 1
+#endif
+
+// Fake include guards to prevent inclusion of some CUDA headers.
+#define __HOST_DEFINES_H__
+#define __DEVICE_LAUNCH_PARAMETERS_H__
+#define __TEXTURE_INDIRECT_FUNCTIONS_HPP__
+#define __SURFACE_INDIRECT_FUNCTIONS_HPP__
+
+// Standard CUDA attributes
+#define __constant__ __attribute__((constant))
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __host__ __attribute__((host))
+#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
+#define __shared__ __attribute__((shared))
+
+// Additional macros used throughout CUDA headers.
+#define __align__(x) __attribute__((aligned(x)))
+#define __builtin_align__(x) __align__(x)
+#define __cudart_builtin__
+#define __device_builtin__
+#define __forceinline__ __inline__ __attribute__((always_inline))
+
+#define CUDARTAPI
+#define _CRTIMP
+
+// Texture and surface types are not supported yet.
+#define __device_builtin_surface_type__
+#define __device_builtin_texture_type__
+
+// Inclde support for built-in variables.
+#include "cuda_builtin_vars.h"
+
+// CUDA headers were implemented with the assumption of split-mode
+// compilation and present CUDA functions differently for host and
+// device mode. Typically in host mode they provide declarations with
+// __device__ attribute attached. In device mode we get definitions
+// but *without* __device__ attribute. This does not work well in
+// combined compilation mode used by clang, so we have to trick CUDA
+// headers into something we can use.
+
+// WARNING: Preprocessor hacks below are based on specific of
+// implementation of CUDA-7.0 headers and are expected to break with
+// any other version of CUDA headers.
+
+// libdevice functions in device_functions_decls.h either come with
+// __host__ __device__ attributes or with none at all. Temporarily
+// undefine __host__ so only __device__ is applied.
+#define __CUDACC_RTC__
+#pragma push_macro("__host__")
+#define __host__
+#include "device_functions_decls.h"
+#pragma pop_macro("__host__")
+#undef __CUDACC_RTC__
+
+#include "cuda_runtime.h"
+#include "crt/device_runtime.h"
+
+#if defined(__CUDA_ARCH__)
+// device_functions.hpp and math_functions*.hpp use 'static
+// __forceinline__' (with no __device__) for definitions of device
+// functions. Temporarily redefine __forceinline__ to include
+// __device__.
+#pragma push_macro("__forceinline__")
+#define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+#include "device_functions.h"
+#include "math_functions.h"
+#pragma pop_macro("__forceinline__")
+#else
+#include "device_functions.h"
+#include "math_functions.h"
+#endif
+
+#if defined(__CUDA_ARCH__)
+// Definitions for device specific functions are provided only if
+// __CUDACC__ is defined. Alas, they've already been transiently
+// included by device_functions.h and are now behind include guards.
+// We need to temporarily define __CUDACC__, undo include guards and
+// include the files with implmentation of these functions.
+
+#pragma push_macro("__CUDACC__")
+#define __CUDACC__ 1
+#undef __DEVICE_ATOMIC_FUNCTIONS_HPP__
+#include "device_atomic_functions.hpp"
+
+#undef __SM_20_ATOMIC_FUNCTIONS_HPP__
+#include "sm_20_atomic_functions.hpp"
+#undef __SM_32_ATOMIC_FUNCTIONS_HPP__
+#include "sm_32_atomic_functions.hpp"
+
+#undef __SM_20_INTRINSICS_HPP__
+#include "sm_20_intrinsics.hpp"
+#undef __SM_30_INTRINSICS_HPP__
+#include "sm_30_intrinsics.hpp"
+#undef __SM_32_INTRINSICS_HPP__
+#include "sm_32_intrinsics.hpp"
+
+#pragma pop_macro("__CUDACC__")
+
+// Cuda headers pull in stdlib.h on the host side of compilation, and
+// a lot of existing CUDA code assumes it. Because clang sees both
+// host and device side of CUDA code simultaneously, we've got to
+// include stdlib.h on device side as well.
+
+#include 
+
+#endif  // __CUDA_ARCH__
+#endif // __PTX__
+#endif // __CLANG_CUDA_SUPPORT_H__
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -17,6 +17,7 @@
   bmiintrin.h
   cpuid.h
   cuda_builtin_vars.h
+  clang_cuda_support.h
   

Re: [PATCH] D13157: Teach -Wtautological-overlap-compare about enums

2015-09-25 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: lib/Analysis/CFG.cpp:54
@@ +53,3 @@
+auto *DR = dyn_cast(E->IgnoreParenImpCasts());
+if (DR == nullptr)
+  return nullptr;

aaron.ballman wrote:
> Please don't compare a pointer against nullptr with an equality operator. 
> This can be simplified into:
> 
> ```
> if (const auto *DR = dyn_cast<>)
>   return isa<> ? "
> return nullptr;
> ```
Thanks for catching that!


Comment at: lib/Analysis/CFG.cpp:97
@@ +96,3 @@
+  // Currently we're only given EnumConstantDecls or IntegerLiterals
+  auto *C1 = cast(cast(A)->getDecl());
+  auto *C2 = cast(cast(B)->getDecl());

aaron.ballman wrote:
> Are you sure that A and B will only ever be DeclRefExprs? You dyn_cast 
> elsewhere.
I'm 100% sure if my code matches my intent exactly. ;)

This helper exists solely to make `checkIncorrectLogicOperator` a bit cleaner 
-- by the time we call it there, we can assume `tryNormalizeBinaryOperator` 
succeeded on both BinOps, and `tryNormalizeBinaryOperator` only returns 
`DeclRefExpr`s (that contain `EnumConstantDecl`s) or `IntegerLiteral`s.

I see that this is unclear though, so I added a line to the function comment to 
make this constraint more explicit. If you think it would be better, I can also 
just manually inline this code in `checkIncorrectLogicOperator`.


http://reviews.llvm.org/D13157



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


Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-25 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 35747.
tra added a comment.

Fixed typos and whitespace nits.
use #pragma push_macro for __CUDACC_RTC__, too.


http://reviews.llvm.org/D13171

Files:
  lib/Headers/CMakeLists.txt
  lib/Headers/clang_cuda_support.h

Index: lib/Headers/clang_cuda_support.h
===
--- /dev/null
+++ lib/Headers/clang_cuda_support.h
@@ -0,0 +1,121 @@
+#ifndef __CLANG_CUDA_SUPPORT_H__
+#define __CLANG_CUDA_SUPPORT_H__
+
+#if defined(__PTX__)
+
+#define __NVCC__ 1
+#if defined(__CUDA_ARCH__)
+#define __CUDABE__ 1
+#else
+#define __CUDACC__ 1
+#endif
+
+// Fake include guards to prevent inclusion of some CUDA headers.
+#define __HOST_DEFINES_H__
+#define __DEVICE_LAUNCH_PARAMETERS_H__
+#define __TEXTURE_INDIRECT_FUNCTIONS_HPP__
+#define __SURFACE_INDIRECT_FUNCTIONS_HPP__
+
+// Standard CUDA attributes
+#define __constant__ __attribute__((constant))
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __host__ __attribute__((host))
+#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
+#define __shared__ __attribute__((shared))
+
+// Additional macros used throughout CUDA headers.
+#define __align__(x) __attribute__((aligned(x)))
+#define __builtin_align__(x) __align__(x)
+#define __cudart_builtin__
+#define __device_builtin__
+#define __forceinline__ __inline__ __attribute__((always_inline))
+
+#define CUDARTAPI
+#define _CRTIMP
+
+// Texture and surface types are not supported yet.
+#define __device_builtin_surface_type__
+#define __device_builtin_texture_type__
+
+// Include support for built-in variables.
+#include "cuda_builtin_vars.h"
+
+// CUDA headers were implemented with the assumption of split-mode
+// compilation and present CUDA functions differently for host and
+// device mode. Typically in host mode they provide declarations with
+// __device__ attribute attached. In device mode we get definitions
+// but *without* __device__ attribute. This does not work well in
+// combined compilation mode used by clang, so we have to trick CUDA
+// headers into something we can use.
+
+// WARNING: Preprocessor hacks below are based on specific of
+// implementation of CUDA-7.0 headers and are expected to break with
+// any other version of CUDA headers.
+
+// libdevice functions in device_functions_decls.h either come with
+// __host__ __device__ attributes or with none at all. Temporarily
+// undefine __host__ so only __device__ is applied.
+#pragma push_macro("__CUDACC_RTC__")
+#pragma push_macro("__host__")
+#define __CUDACC_RTC__
+#define __host__
+#include "device_functions_decls.h"
+#pragma pop_macro("__host__")
+#pragma pop_macro("__CUDACC_RTC__")
+
+#include "cuda_runtime.h"
+#include "crt/device_runtime.h"
+
+#if defined(__CUDA_ARCH__)
+// device_functions.hpp and math_functions*.hpp use 'static
+// __forceinline__' (with no __device__) for definitions of device
+// functions. Temporarily redefine __forceinline__ to include
+// __device__.
+#pragma push_macro("__forceinline__")
+#define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+#include "device_functions.h"
+#include "math_functions.h"
+#pragma pop_macro("__forceinline__")
+#else
+#include "device_functions.h"
+#include "math_functions.h"
+#endif
+
+#if defined(__CUDA_ARCH__)
+// Definitions for device specific functions are provided only if
+// __CUDACC__ is defined. Alas, they've already been transitively
+// included by device_functions.h and are now behind include guards.
+// We need to temporarily define __CUDACC__, undo include guards and
+// include the files with implementation of these functions.
+
+#pragma push_macro("__CUDACC__")
+#define __CUDACC__ 1
+
+#undef __DEVICE_ATOMIC_FUNCTIONS_HPP__
+#include "device_atomic_functions.hpp"
+
+#undef __SM_20_ATOMIC_FUNCTIONS_HPP__
+#include "sm_20_atomic_functions.hpp"
+#undef __SM_32_ATOMIC_FUNCTIONS_HPP__
+#include "sm_32_atomic_functions.hpp"
+
+#undef __SM_20_INTRINSICS_HPP__
+#include "sm_20_intrinsics.hpp"
+#undef __SM_30_INTRINSICS_HPP__
+#include "sm_30_intrinsics.hpp"
+#undef __SM_32_INTRINSICS_HPP__
+#include "sm_32_intrinsics.hpp"
+
+#pragma pop_macro("__CUDACC__")
+
+// Cuda headers pull in stdlib.h on the host side of compilation, and
+// a lot of existing CUDA code assumes it. Because clang sees both
+// host and device side of CUDA code simultaneously, we've got to
+// include stdlib.h on device side as well.
+
+#include 
+
+#endif // __CUDA_ARCH__
+#endif // __PTX__
+#endif // __CLANG_CUDA_SUPPORT_H__
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -17,6 +17,7 @@
   bmiintrin.h
   cpuid.h
   cuda_builtin_vars.h
+  clang_cuda_support.h
   emmintrin.h
   f16cintrin.h
   float.h
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D13170: [CUDA] Driver changes to pass flags needed to use detected CUDA installation.

2015-09-25 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added a reviewer: echristo.
tra added a subscriber: cfe-commits.

  - added detection of libdevice bitcode file and API to find one appropriate 
for the GPU we're compiling for.
  - added include paths to detected CUDA installation
  - added include paths for -aux-triple
  - added flags for linking in detected libdevice bitcode
  - added -nocudalib/-nocudainc to prevent automatic linking with libdevice of 
adding CUDA include path.
  - added test cases to verify new functionality



http://reviews.llvm.org/D13170

Files:
  include/clang/Driver/Driver.h
  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
  lib/Driver/Tools.h
  test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/.keep
  
test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc
  
test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_35.10.bc
  test/Driver/cuda-detect.cu

Index: test/Driver/cuda-detect.cu
===
--- test/Driver/cuda-detect.cu
+++ test/Driver/cuda-detect.cu
@@ -1,10 +1,56 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 //
+// # Check that we properly detect CUDA installation.
 // RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --sysroot=/tmp/no-cuda-there 2>&1 | FileCheck %s -check-prefix NOCUDA
 // RUN: %clang -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
+// RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
 
+// Make sure we map libdevice bitcode files to proper GPUs.
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_21 \
+// RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix LIBDEVICE -check-prefix LIBDEVICE21
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix LIBDEVICE -check-prefix LIBDEVICE35 \
+// RUN:   -check-prefix CUDAINC
+// Verify that -nocudainc prevents adding include path to CUDA headers.
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
+// RUN:   -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix LIBDEVICE -check-prefix LIBDEVICE35 \
+// RUN:   -check-prefix NOCUDAINC
+
+// Verify that no options related to bitcode linking are passes if
+// there's no bitcode file.
+// 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 NOLIBDEVICE
+// .. or if we explicitly passed -nocudalib
+// 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:   | FileCheck %s -check-prefix NOLIBDEVICE
+
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
 // NOCUDA-NOT: Found CUDA installation:
+
+// LIBDEVICE: "-triple" "nvptx-nvidia-cuda"
+// LIBDEVICE-SAME: "-fcuda-is-device"
+// LIBDEVICE-SAME: "-mlink-bitcode-file"
+// LIBDEVICE21-SAME: libdevice.compute_20.10.bc
+// LIBDEVICE35-SAME: libdevice.compute_35.10.bc
+// LIBDEVICE-SAME: "-fcuda-uses-libdevice"
+// LIBDEVICE-SAME: "-target-feature" "+ptx42"
+// CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA/usr/local/cuda/include"
+// NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/Inputs/CUDA/usr/local/cuda/include"
+// LIBDEVICE-SAME: "-x" "cuda"
+
+// NOLIBDEVICE: "-triple" "nvptx-nvidia-cuda"
+// NOLIBDEVICE-SAME: "-fcuda-is-device"
+// NOLIBDEVICE-NOT: "-mlink-bitcode-file"
+// NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc
+// NOLIBDEVICE-NOT: "-fcuda-uses-libdevice"
+// NOLIBDEVICE-NOT: "-target-feature"
+// NOLIBDEVICE-SAME: "-x" "cuda"
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -55,7 +55,8 @@
const Driver , const llvm::opt::ArgList ,
llvm::opt::ArgStringList ,
const InputInfo ,
-   const InputInfoList ) const;
+   const InputInfoList ,
+   const char *AuxTriple) const;
 
   void AddAArch64TargetArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -248,7 +248,8 @@
 const Driver , const ArgList ,
 ArgStringList ,
 

Re: [PATCH] D12996: Driver: support ARM/HF on a single toolchain

2015-09-25 Thread Jonathan Roelofs via cfe-commits
jroelofs accepted this revision.
jroelofs added a reviewer: jroelofs.
jroelofs added a comment.
This revision is now accepted and ready to land.

Now that you've got http://reviews.llvm.org/D13155 squared away, LGTM.


http://reviews.llvm.org/D12996



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


Re: [PATCH] D13105: [OpenCL] Enable program scope variables for OpenCL2.0

2015-09-25 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 35732.
Anastasia added a comment.

Thanks! The review comments are addressed in this update!


http://reviews.llvm.org/D13105

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  lib/AST/Decl.cpp
  lib/AST/DeclPrinter.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaDecl.cpp
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/storageclass-cl20.cl
  test/SemaOpenCL/storageclass.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6604,8 +6604,6 @@
 return CX_SC_Static;
   case SC_PrivateExtern:
 return CX_SC_PrivateExtern;
-  case SC_OpenCLWorkGroupLocal:
-return CX_SC_OpenCLWorkGroupLocal;
   case SC_Auto:
 return CX_SC_Auto;
   case SC_Register:
Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -1,14 +1,29 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-static constant int A = 0;
+static constant int G1 = 0;
+constant int G2 = 0;
+int G3 = 0;// expected-error{{program scope variable must reside in constant address space}}
+global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
 
-int X = 0; // expected-error{{global variables must have a constant address space qualifier}}
-
-// static is not allowed at local scope.
 void kernel foo() {
-  static int X = 5; // expected-error{{variables in function scope cannot be declared static}} 
-  auto int Y = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
+  // static is not allowed at local scope before CL2.0
+  static int S1 = 5;  // expected-error{{variables in function scope cannot be declared static}}
+  static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}}
+
+  constant int L1 = 0;
+  local int L2;
+
+  auto int L3 = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
 }
 
 static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
 }
+
+void f() {
+  constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
+  local int L2;// expected-error{{non-kernel function variable cannot be declared in local address space}}
+  {
+constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
+local int L2;// expected-error{{non-kernel function variable cannot be declared in local address space}}
+  }
+}
Index: test/SemaOpenCL/storageclass-cl20.cl
===
--- /dev/null
+++ test/SemaOpenCL/storageclass-cl20.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCL20 -cl-std=CL2.0
+
+static constant int G1 = 0;
+int G2 = 0;// expected-error{{program scope variable must reside in global or constant address space}}
+global int G3 = 0;
+local int G4 = 0;// expected-error{{program scope variable must reside in global or constant address space}}
+
+void kernel foo() {
+  static int S1 = 5;// expected-error{{program scope variable must reside in global or constant address space}}
+  static global int S2 = 5;
+  static private int S3 = 5;// expected-error{{program scope variable must reside in global or constant address space}}
+
+  constant int L1 = 0;
+  local int L2;
+}
Index: test/Parser/opencl-storage-class.cl
===
--- test/Parser/opencl-storage-class.cl
+++ test/Parser/opencl-storage-class.cl
@@ -8,7 +8,7 @@
   auto int d;  // expected-error {{OpenCL does not support the 'auto' storage class specifier}}
 
 #pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
-  static int e;
+  static int e; // expected-error {{program scope variable must reside in constant address space}}
   register int f;
   extern int g;
   auto int h;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5687,12 +5687,6 @@
   }
 
   if (getLangOpts().OpenCL) {
-// Set up the special work-group-local storage class for variables in the
-// OpenCL __local address space.
-if (R.getAddressSpace() == LangAS::opencl_local) {
-  SC = SC_OpenCLWorkGroupLocal;
-}
-
 // OpenCL v1.2 s6.9.b p4:
 // The sampler type cannot be used with the __local and __global address
 // space qualifiers.
@@ -5759,8 +5753,6 @@
 break;
   case SC_PrivateExtern:
 llvm_unreachable("C storage class in c++!");
-  case SC_OpenCLWorkGroupLocal:
-llvm_unreachable("OpenCL storage class in 

r248592 - The Clang gcc-compatible driver (clang/tools/driver/driver.cpp) has some

2015-09-25 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Sep 25 12:44:31 2015
New Revision: 248592

URL: http://llvm.org/viewvc/llvm-project?rev=248592=rev
Log:
The Clang gcc-compatible driver (clang/tools/driver/driver.cpp) has some
logic to select an alternate target based on the executable it was
called as. For instance, if you symlink i686-linux-android-gcc to clang
and invoke it, the driver will act as though it were called with another
argument ("-target i686-linux-android"). This leads to visible effects
even in syntax-only compilations (like the ANDROID preprocessor symbol
being defined).

This behavior is not replicated for tool invocations--for instance,
clang::createInvocationFromCommandLine will not choose an alternate
target based on ArgList[0]. This means that configurations stored in
compilation databases aren't accurately replayed.

This patch separates the logic for selecting a mode flag and target from
the executable name into a new member function on ToolChain. It should
have no functional effects (but will allow other code to reuse the
target/mode selection logic).

Patch by Luke Zarko!

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=248592=248591=248592=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Sep 25 12:44:31 2015
@@ -151,6 +151,20 @@ public:
   // Returns the RTTIMode for the toolchain with the current arguments.
   RTTIMode getRTTIMode() const { return CachedRTTIMode; }
 
+  /// \brief Return any implicit target and/or mode flag for an invocation of
+  /// the compiler driver as `ProgName`.
+  ///
+  /// For example, when called with i686-linux-android-g++, the first element
+  /// of the return value will be set to `"i686-linux-android"` and the second
+  /// will be set to "--driver-mode=g++"`.
+  ///
+  /// \pre `llvm::InitializeAllTargets()` has been called.
+  /// \param ProgName The name the Clang driver was invoked with (from,
+  /// e.g., argv[0])
+  /// \return A pair of (`target`, `mode-flag`), where one or both may be 
empty.
+  static std::pair
+  getTargetAndModeFromProgramName(StringRef ProgName);
+
   // Tool access.
 
   /// TranslateArgs - Create a new derived argument list for any argument

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=248592=248591=248592=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Sep 25 12:44:31 2015
@@ -22,6 +22,7 @@
 #include "llvm/Option/Option.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/TargetRegistry.h"
 using namespace clang::driver;
 using namespace clang;
 using namespace llvm::opt;
@@ -88,6 +89,99 @@ const SanitizerArgs& ToolChain::getSanit
   return *SanitizerArguments.get();
 }
 
+namespace {
+struct DriverSuffix {
+  const char *Suffix;
+  const char *ModeFlag;
+};
+
+const DriverSuffix *FindDriverSuffix(StringRef ProgName) {
+  // A list of known driver suffixes. Suffixes are compared against the
+  // program name in order. If there is a match, the frontend type is updated 
as
+  // necessary by applying the ModeFlag.
+  static const DriverSuffix DriverSuffixes[] = {
+  {"clang", nullptr},
+  {"clang++", "--driver-mode=g++"},
+  {"clang-c++", "--driver-mode=g++"},
+  {"clang-cc", nullptr},
+  {"clang-cpp", "--driver-mode=cpp"},
+  {"clang-g++", "--driver-mode=g++"},
+  {"clang-gcc", nullptr},
+  {"clang-cl", "--driver-mode=cl"},
+  {"cc", nullptr},
+  {"cpp", "--driver-mode=cpp"},
+  {"cl", "--driver-mode=cl"},
+  {"++", "--driver-mode=g++"},
+  };
+
+  for (size_t i = 0; i < llvm::array_lengthof(DriverSuffixes); ++i)
+if (ProgName.endswith(DriverSuffixes[i].Suffix))
+  return [i];
+  return nullptr;
+}
+
+/// Normalize the program name from argv[0] by stripping the file extension if
+/// present and lower-casing the string on Windows.
+std::string normalizeProgramName(llvm::StringRef Argv0) {
+  std::string ProgName = llvm::sys::path::stem(Argv0);
+#ifdef LLVM_ON_WIN32
+  // Transform to lowercase for case insensitive file systems.
+  std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(), 
::tolower);
+#endif
+  return ProgName;
+}
+
+const DriverSuffix *parseDriverSuffix(StringRef ProgName) {
+  // Try to infer frontend type and default target from the program name by
+  // comparing it against DriverSuffixes in order.
+
+  // If there is a match, the function tries to identify a target as prefix.
+  // E.g. 

[PATCH] D13168: [OpenCL] OpenCL2.0 - Apply default address space rules

2015-09-25 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: pekka.jaaskelainen.
Anastasia added a subscriber: cfe-commits.

If address space (AS) of a variable/parameter declaration is not set, OpenCL2.0 
s6.5 defines explicit rules for default ASes:

- The AS of global and local static variables defaults to global;
- All pointers point to generic AS.

http://reviews.llvm.org/D13168

Files:
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/address-spaces.cl
  test/SemaOpenCL/storageclass-cl20.cl

Index: test/SemaOpenCL/storageclass-cl20.cl
===
--- test/SemaOpenCL/storageclass-cl20.cl
+++ test/SemaOpenCL/storageclass-cl20.cl
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCL20 -cl-std=CL2.0
 
 static constant int G1 = 0;
-int G2 = 0;// expected-error{{program scope variable must reside in global or constant address space}}
+int G2 = 0;
 global int G3 = 0;
 local int G4 = 0;// expected-error{{program scope variable must reside in global or constant address space}}
 
 void kernel foo() {
-  static int S1 = 5;// expected-error{{program scope variable must reside in global or constant address space}}
+  static int S1 = 5;
   static global int S2 = 5;
   static private int S3 = 5;// expected-error{{program scope variable must reside in global or constant address space}}
 
Index: test/CodeGenOpenCL/address-spaces.cl
===
--- test/CodeGenOpenCL/address-spaces.cl
+++ test/CodeGenOpenCL/address-spaces.cl
@@ -1,27 +1,47 @@
-// RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefix=CL20
 
-void f__p(__private int *arg) { }
-// CHECK: i32* nocapture %arg
+// CHECK: i32* %arg
+void f__p(__private int *arg) {}
 
-void f__g(__global int *arg) { }
-// CHECK: i32 addrspace(1)* nocapture %arg
+// CHECK: i32 addrspace(1)* %arg
+void f__g(__global int *arg) {}
 
-void f__l(__local int *arg) { }
-// CHECK: i32 addrspace(2)* nocapture %arg
+// CHECK: i32 addrspace(2)* %arg
+void f__l(__local int *arg) {}
 
-void f__c(__constant int *arg) { }
-// CHECK: i32 addrspace(3)* nocapture %arg
+// CHECK: i32 addrspace(3)* %arg
+void f__c(__constant int *arg) {}
 
+// CHECK: i32* %arg
+void fp(private int *arg) {}
 
-void fp(private int *arg) { }
-// CHECK: i32* nocapture %arg
+// CHECK: i32 addrspace(1)* %arg
+void fg(global int *arg) {}
 
-void fg(global int *arg) { }
-// CHECK: i32 addrspace(1)* nocapture %arg
+// CHECK: i32 addrspace(2)* %arg
+void fl(local int *arg) {}
 
-void fl(local int *arg) { }
-// CHECK: i32 addrspace(2)* nocapture %arg
+// CHECK: i32 addrspace(3)* %arg
+void fc(constant int *arg) {}
 
-void fc(constant int *arg) { }
-// CHECK: i32 addrspace(3)* nocapture %arg
+#ifdef CL20
+int i;
+// CL20-DAG: @i = common addrspace(1) global i32 0
+int *ptr;
+// CL20-DAG: @ptr = common addrspace(1) global i32 addrspace(4)* null
+#endif
 
+// CHECK: i32* %arg
+// CL20-DAG: i32 addrspace(4)* %arg
+void f(int *arg) {
+
+  int i;
+// CHECK: %i = alloca i32,
+// CL20-DAG: %i = alloca i32,
+
+#ifdef CL20
+  static int ii;
+// CL20-DAG: @f.ii = internal addrspace(1) global i32 0
+#endif
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1545,8 +1545,7 @@
   // Apply any type attributes from the decl spec.  This may cause the
   // list of type attributes to be temporarily saved while the type
   // attributes are pushed around.
-  if (AttributeList *attrs = DS.getAttributes().getList())
-processTypeAttrs(state, Result, TAL_DeclSpec, attrs);
+  processTypeAttrs(state, Result, TAL_DeclSpec, DS.getAttributes().getList());
 
   // Apply const/volatile/restrict qualifiers to T.
   if (unsigned TypeQuals = DS.getTypeQualifiers()) {
@@ -2580,8 +2579,8 @@
 // Constructors and destructors don't have return types. Use
 // "void" instead.
 T = SemaRef.Context.VoidTy;
-if (AttributeList *attrs = D.getDeclSpec().getAttributes().getList())
-  processTypeAttrs(state, T, TAL_DeclSpec, attrs);
+processTypeAttrs(state, T, TAL_DeclSpec,
+ D.getDeclSpec().getAttributes().getList());
 break;
 
   case UnqualifiedId::IK_ConversionFunctionId:
@@ -4071,8 +4070,8 @@
 }
 
 // See if there are any attributes on this declarator chunk.
-if (AttributeList *attrs = const_cast(DeclType.getAttrs()))
-  processTypeAttrs(state, T, TAL_DeclChunk, attrs);
+processTypeAttrs(state, T, TAL_DeclChunk,
+ const_cast(DeclType.getAttrs()));
   }
 
   assert(!T.isNull() && "T must not be null after this point");
@@ -4165,8 +4164,7 @@
   }
 
   // Apply any undistributed attributes from the declarator.
-  

Re: [PATCH] D12982: Move routines for guessing mode/target from driver to ToolChain

2015-09-25 Thread Eric Christopher via cfe-commits
Oh, sure I can.

Done thusly:

dzur:~/sources/llvm/tools/clang> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
M include/clang/Driver/ToolChain.h
M lib/Driver/ToolChain.cpp
M tools/driver/driver.cpp
Committed r248592

-eric


On Fri, Sep 25, 2015 at 10:20 AM Luke Zarko  wrote:

> zarko added a comment.
>
> Great!
>
> I don't have commit access; would someone who does please land this?
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D12982
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] __attribute__((enable_if)) and non-overloaded member functions

2015-09-25 Thread George Burgess via cfe-commits
Sorry for the delay -- didn't see this email come in.

Committed as r248595. :)

On Tue, Sep 22, 2015 at 1:06 PM, Ettore Speziale 
wrote:

> Hello,
>
> > Looks good to me!
> >
> > Do you have commit access, or would you like for me to commit it for you?
>
> I do not have commit access. It would be great if you can commit for me.
>
> Thanks,
> Ettore Speziale
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12666: [LibClang] Fix clang_getCursorAvailability

2015-09-25 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Submitted as  r248596. Sergey, if you plan to work on libclang more, please
get commit access (it's easy :) Thx


http://reviews.llvm.org/D12666



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


Re: [PATCH] D12666: [LibClang] Fix clang_getCursorAvailability

2015-09-25 Thread Manuel Klimek via cfe-commits
Submitted as  r248596. Sergey, if you plan to work on libclang more, please
get commit access (it's easy :) Thx

On Fri, Sep 18, 2015 at 5:25 AM Milian Wolff  wrote:

> milianw added a subscriber: milianw.
> milianw added a comment.
>
> Ping? Can someone please submit this upstream?
>
>
> http://reviews.llvm.org/D12666
>
>
>
>
___
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

2015-09-25 Thread Alexander Droste via cfe-commits
Alexander_Droste added inline comments.


Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerPathSensitive.cpp:35
@@ +34,3 @@
+  if (!isa(MR) ||
+  (ER && !isa(ER->getSuperRegion(
+return;

Thanks for the hint! I tried `iterBindings`  but can't get it to add more 
functionality.   
It seems to me that only `TypedRegion`s are iterable.


http://reviews.llvm.org/D12761



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


r248626 - Relax test to allow for __attribute__((thiscall)). Under Win32 c-index-test output is

2015-09-25 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri Sep 25 17:09:07 2015
New Revision: 248626

URL: http://llvm.org/viewvc/llvm-project?rev=248626=rev
Log:
Relax test to allow for __attribute__((thiscall)). Under Win32 c-index-test 
output is

CXXMethod=foo:4:7 (unavailable) [type=int () __attribute__((thiscall))] 
[typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
CXXConstructor=Foo:5:3 (unavailable) [type=void () __attribute__((thiscall))] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]


Modified:
cfe/trunk/test/Index/availability.cpp

Modified: cfe/trunk/test/Index/availability.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/availability.cpp?rev=248626=248625=248626=diff
==
--- cfe/trunk/test/Index/availability.cpp (original)
+++ cfe/trunk/test/Index/availability.cpp Fri Sep 25 17:09:07 2015
@@ -9,5 +9,5 @@ struct Foo {
 // RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s
 // CHECK: FunctionDecl=foo:1:6 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
 // CHECK: StructDecl=Foo:3:8 (Definition) [type=Foo] [typekind=Record] 
[isPOD=1]
-// CHECK: CXXMethod=foo:4:7 (unavailable) [type=int ()] 
[typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
-// CHECK: CXXConstructor=Foo:5:3 (unavailable) [type=void ()] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]
+// CHECK: CXXMethod=foo:4:7 (unavailable) [type=int (){{.*}}] 
[typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
+// CHECK: CXXConstructor=Foo:5:3 (unavailable) [type=void (){{.*}}] 
[typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]


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


[PATCH] D13187: [Clang] Fix Clang-tidy modernize-use-nullptr warnings in headers and generated files; other minor cleanups.

2015-09-25 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added a reviewer: hans.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

Also fixed Clang-tidy readability-simplify-boolean-expr in 
tools/libclang/CIndex.cpp.

I checked this patch on my own build on RHEL 6. Regressions were OK.

Please check it in if it's OK, because I don't have SVN write access.

Repository:
  rL LLVM

http://reviews.llvm.org/D13187

Files:
  include/clang/AST/Expr.h
  include/clang/AST/OpenMPClause.h
  include/clang/Analysis/CFG.h
  include/clang/Basic/Attr.td
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/TargetInfo.h
  lib/Sema/TreeTransform.h
  tools/libclang/CIndex.cpp
  utils/TableGen/ClangAttrEmitter.cpp
  utils/TableGen/ClangCommentCommandInfoEmitter.cpp

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -316,7 +316,7 @@
  llvm::Value *storage,
  CGBuilderTy ,
  const CGBlockInfo ,
- llvm::Instruction *InsertPoint = 0);
+ llvm::Instruction *InsertPoint = nullptr);
 
   /// Emit call to \c llvm.dbg.declare for an argument variable
   /// declaration.
@@ -581,4 +581,4 @@
 } // namespace CodeGen
 } // namespace clang
 
-#endif
+#endif // LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -47,7 +47,7 @@
 
 public:
   // WARNING: Acquires the ownership of ABIInfo.
-  TargetCodeGenInfo(ABIInfo *info = 0) : Info(info) {}
+  TargetCodeGenInfo(ABIInfo *info = nullptr) : Info(info) {}
   virtual ~TargetCodeGenInfo();
 
   /// getABIInfo() - Returns ABI info helper for the target.
@@ -219,6 +219,6 @@
llvm::StringRef Value,
llvm::SmallString<32> ) const {}
 };
-}
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -715,7 +715,7 @@
 
   /// Return the address of the given function. If Ty is non-null, then this
   /// function will use the specified type if it has to create it.
-  llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = 0,
+  llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = nullptr,
 bool ForVTable = false,
 bool DontDefer = false,
 bool IsForDefinition = false);
@@ -1184,7 +1184,7 @@
 
   // FIXME: Hardcoding priority here is gross.
   void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
- llvm::Constant *AssociatedData = 0);
+ llvm::Constant *AssociatedData = nullptr);
   void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535);
 
   /// Generates a global array of functions and priorities using the given list
@@ -1251,4 +1251,4 @@
 }  // end namespace CodeGen
 }  // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -7266,7 +7266,7 @@
 TreeTransform::TransformOMPCollapseClause(OMPCollapseClause *C) {
   ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
   if (E.isInvalid())
-return 0;
+return nullptr;
   return getDerived().RebuildOMPCollapseClause(
   E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
 }
@@ -11235,4 +11235,4 @@
 
 } // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1523,10 +1523,7 @@
 }
 
 bool CursorVisitor::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
-  if (Visit(MakeCursorObjCClassRef(TL.getIFaceDecl(), TL.getNameLoc(), TU)))
-return true;
-
-  return false;
+  return Visit(MakeCursorObjCClassRef(TL.getIFaceDecl(), TL.getNameLoc(), TU));
 }
 
 bool CursorVisitor::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
@@ -1644,10 +1641,7 @@
 }
 
 bool CursorVisitor::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
-  if (VisitNestedNameSpecifierLoc(TL.getQualifierLoc()))
-return true;
-  
-  return false;
+  return VisitNestedNameSpecifierLoc(TL.getQualifierLoc());
 }
 
 bool CursorVisitor::VisitDependentTemplateSpecializationTypeLoc(
Index: 

Re: [PATCH] D12251: Analyzer: Calculate field offset correctly

2015-09-25 Thread Devin Coughlin via cfe-commits
dcoughlin requested changes to this revision.
dcoughlin added a comment.
This revision now requires changes to proceed.

Thanks for the patch Ismail! Some comments inline.



Comment at: lib/StaticAnalyzer/Core/Store.cpp:408
@@ +407,3 @@
+if (!Base.isZeroConstant()) {
+  if (const FieldDecl *FD = dyn_cast(D)) {
+ASTContext  = D->getASTContext();

You can use `auto *FD = dyn_cast(D)` here to avoid repeating 
the type.


Comment at: lib/StaticAnalyzer/Core/Store.cpp:410
@@ +409,3 @@
+ASTContext  = D->getASTContext();
+CharUnits CU = Ctx.toCharUnitsFromBits(Ctx.getFieldOffset(FD));
+loc::ConcreteInt BasePtr = BaseL.castAs();

`getFieldOffset()` will assert when the field is an Objective-C instance 
variable because it expects the field's parent to be a record. For example: 
`int *x = &((SomeClass *)0x10)->someIVar;`


Comment at: test/Analysis/array-struct-region.cpp:128
@@ -109,1 +127,3 @@
+#endif
+}
 

This test doesn't cover the new logic you added in Store.cpp because it is 
never the case in this test that the base is a non-zero ConcreteInt Loc. In 
addition to your test with `PFONull`, you should add tests with something like 
`struct FieldOffset *PFOConstant = (struct FieldOffset *) 0x22;`. I think it is 
also important to add tests for Objective-C instance variables after addressing 
the assertion failure in that case.


http://reviews.llvm.org/D12251



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


r248645 - Replace a loop and temporary string copying with llvm::join.

2015-09-25 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Sep 25 20:25:08 2015
New Revision: 248645

URL: http://llvm.org/viewvc/llvm-project?rev=248645=rev
Log:
Replace a loop and temporary string copying with llvm::join.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=248645=248644=248645=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Sep 25 20:25:08 2015
@@ -14,6 +14,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -455,13 +456,8 @@ TargetMachine *EmitAssemblyHelper::Creat
   llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
 BackendArgs.data());
 
-  std::string FeaturesStr;
-  if (!TargetOpts.Features.empty()) {
-SubtargetFeatures Features;
-for (const std::string  : TargetOpts.Features)
-  Features.AddFeature(Feature);
-FeaturesStr = Features.getString();
-  }
+  std::string FeaturesStr =
+  llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
 
   // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
   llvm::Reloc::Model RM = llvm::Reloc::Default;


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


Re: [PATCH] D13128: Fix backend crash on multiple close of stdout.

2015-09-25 Thread Dan Gohman via cfe-commits
sunfish added a comment.

This code has been questioned in this way before, and every time it comes up, 
it turns out that there's a bug somewhere else that really ought to be fixed 
anyway.

In previous iterations of this discussion, when clang is found attempting to 
print something like a dep file to the same stream as the normal compiler 
output file, this is not actually desirable behavior because it mixes two 
different kinds of output. Besides the fact that this typically isn't what a 
user actually wants, it can cause serious problems if one of the stream needs 
to use "binary" mode and the other doesn't, for example.

The resolution has been to have clang issue an error if the dep file and the 
output file are both using stdout, which is nice to do, because if a user is 
asking for this it's likely not intentional. With this done, there is no longer 
a way to crash the compiler, and there's no need to change how raw_fd_ostream 
works.


http://reviews.llvm.org/D13128



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


Re: [PATCH] D12633: Implement ACLE 2.0 macros of chapters 6.6 and 6.7 for [ARM] and [Aarch64] targets

2015-09-25 Thread Alexandros Lamprineas via cfe-commits
labrinea added a comment.

In http://reviews.llvm.org/D12633#252758, @labrinea wrote:

> @t.p.northover I think we should not be defining _ARM_FP_FENV_ROUNDING on 
> neither of ARM and AArch64 targets since "-frounding-math" is not available 
> on clang: clang/llvm don't support C99 FP rounding mode pragmas (FENV_ACCESS 
> etc) 
>
> > @t.p.northover : "Ah, that constant folding is definitely a problem. 
> > Changing it sounds reasonable.
>
> > Tim."
>


(attaching Tim's comment since it was missing from the phabricator thread)


http://reviews.llvm.org/D12633



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


r248569 - [OPENMP 4.1] Add 'threads' clause for '#pragma omp ordered'.

2015-09-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Sep 25 05:37:12 2015
New Revision: 248569

URL: http://llvm.org/viewvc/llvm-project?rev=248569=rev
Log:
[OPENMP 4.1] Add 'threads' clause for '#pragma omp ordered'.
OpenMP 4.1 extends format of '#pragma omp ordered'. It adds 3 additional 
clauses: 'threads', 'simd' and 'depend'.
If no clause is specified, the ordered construct behaves as if the threads 
clause had been specified. If the threads clause is specified, the threads in 
the team executing the loop region execute ordered regions sequentially in the 
order of the loop iterations.
The loop region to which an ordered region without any clause or with a threads 
clause binds must have an ordered clause without the parameter specified on the 
corresponding loop directive.

Modified:
cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/ordered_ast_print.cpp
cfe/trunk/test/OpenMP/ordered_codegen.cpp
cfe/trunk/test/OpenMP/ordered_messages.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=248569=248568=248569=diff
==
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Fri Sep 25 05:37:12 
2015
@@ -2535,6 +2535,11 @@ bool RecursiveASTVisitor::Visit
 }
 
 template 
+bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
+  return true;
+}
+
+template 
 template 
 bool RecursiveASTVisitor::VisitOMPClauseList(T *Node) {
   for (auto *E : Node->varlists()) {

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=248569=248568=248569=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Sep 25 05:37:12 2015
@@ -2530,6 +2530,37 @@ public:
   child_range children() { return child_range(,  + 1); }
 };
 
+/// \brief This represents 'threads' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp ordered threads
+/// \endcode
+/// In this example directive '#pragma omp ordered' has simple 'threads' 
clause.
+///
+class OMPThreadsClause : public OMPClause {
+public:
+  /// \brief Build 'threads' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  ///
+  OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_threads, StartLoc, EndLoc) {}
+
+  /// \brief Build an empty clause.
+  ///
+  OMPThreadsClause()
+  : OMPClause(OMPC_threads, SourceLocation(), SourceLocation()) {}
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_threads;
+  }
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+};
+
 } // end namespace clang
 
 #endif

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=248569=248568=248569=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Sep 25 05:37:12 2015
@@ -2567,6 +2567,11 @@ bool RecursiveASTVisitor::Visit
 }
 
 template 
+bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
+  return true;
+}
+
+template 
 template 
 bool RecursiveASTVisitor::VisitOMPClauseList(T *Node) {
   for (auto *E : Node->varlists()) {

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=248569=248568=248569=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Sep 25 05:37:12 2015
@@ -1714,16 +1714,21 @@ class OMPOrderedDirective : public OMPEx
   ///
   /// \param StartLoc Starting 

Re: [PATCH] D13157: Teach -Wtautological-overlap-compare about enums

2015-09-25 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

Thank you for working on this -- I think it's a good cleanup and feature-add! I 
have a few minor comments, but generally LGTM. You should wait for an okay from 
Richard, however.



Comment at: lib/Analysis/CFG.cpp:54
@@ +53,3 @@
+auto *DR = dyn_cast(E->IgnoreParenImpCasts());
+if (DR == nullptr)
+  return nullptr;

Please don't compare a pointer against nullptr with an equality operator. This 
can be simplified into:

```
if (const auto *DR = dyn_cast<>)
  return isa<> ? "
return nullptr;
```


Comment at: lib/Analysis/CFG.cpp:97
@@ +96,3 @@
+  // Currently we're only given EnumConstantDecls or IntegerLiterals
+  auto *C1 = cast(cast(A)->getDecl());
+  auto *C2 = cast(cast(B)->getDecl());

Are you sure that A and B will only ever be DeclRefExprs? You dyn_cast 
elsewhere.


http://reviews.llvm.org/D13157



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


r248567 - New test ps4-linker-win.c (added in r48546) is causing problems for Windows bots. I'm deleting this file during investigation.

2015-09-25 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Fri Sep 25 04:10:33 2015
New Revision: 248567

URL: http://llvm.org/viewvc/llvm-project?rev=248567=rev
Log:
New test ps4-linker-win.c (added in r48546) is causing problems for Windows 
bots. I'm deleting this file during investigation.

Removed:
cfe/trunk/test/Driver/ps4-linker-win.c

Removed: cfe/trunk/test/Driver/ps4-linker-win.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-win.c?rev=248566=auto
==
--- cfe/trunk/test/Driver/ps4-linker-win.c (original)
+++ cfe/trunk/test/Driver/ps4-linker-win.c (removed)
@@ -1,26 +0,0 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -linker=gold, or -shared with no -linker option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
-
-// REQUIRES: system-windows, x86-registered-target
-
-// RUN: touch %T/ps4-ld.exe
-// RUN: touch %T/ps4-ld.gold.exe
-
-// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -linker=gold -### 
2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-
-// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -linker=ps4 -### 2>&1 
\
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -linker=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER 
%s
-
-// CHECK-PS4-GOLD: ps4-ld.gold.exe
-// CHECK-PS4-LINKER: ps4-ld.exe


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


Re: [PATCH] D13099: [Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)

2015-09-25 Thread Sean Eveson via cfe-commits
seaneveson added a comment.

I've realized that the patch doesn't handle pointers correctly, since a const 
method can modify the memory pointed at by a member. While pointer members 
should not be invalidated by const methods (if they are not mutable), the 
memory they point to should still be invalidated. I'll address this in the next 
version.

Regarding ConstPointerEscape:

In http://reviews.llvm.org/D13099#253111, @zaks.anna wrote:

> The analyzer has a notion of ConstPointerEscape, see checkConstPointerEscape 
> callback.
>  All the pointers to const parameters are escaped this way. The 
> implementation for that is in CallEvent::invalidateRegions, right below the 
> code you've added:
>
>   ...
>
>
> I think we should const escape all non-mutable fields as well as 'this'.
>
> (A motivation behind this callback is that one can call delete on pointers of 
> const *void type.)


I think I understand, but to clarify:
The fields that shouldn't be invalidated should still be added to 
ValuesToInvalidate, but with 
RegionAndSymbolInvalidationTraits::TK_PreserveContents set. This will result in 
checkConstPointerEscape being called properly.

Is that correct?


http://reviews.llvm.org/D13099



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