Re: [PATCH] [x32] Add X32 support to driver

2014-06-18 Thread Saleem Abdulrasool

Comment at: lib/Basic/Targets.cpp:3262
@@ -3260,4 +3261,3 @@
 SuitableAlign = 128;
-IntMaxType = SignedLong;
-UIntMaxType = UnsignedLong;
-Int64Type = SignedLong;
+if (IsX32) {
+  SizeType = UnsignedInt;

I think chaining the assignment here similar to above might be nicer.


Comment at: lib/Basic/Targets.cpp:3273
@@ -3265,2 +3272,3 @@
 
-DescriptionString = "e-m:e-i64:64-f80:128-n8:16:32:64-S128";
+DescriptionString = (IsX32)
+? "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128"

The two data layouts are identical except for the pointer size.  Can you factor 
that out so that its more obvious and less redundant please?


Comment at: lib/Driver/ToolChains.cpp:2977
@@ -2955,1 +2976,3 @@
 
+  if (Triple.getEnvironment() == llvm::Triple::GNUX32)
+return "libx32";

Can you add a check that arch is x86_64?  Right now, you could make up 
ppc64---gnux32 if Im not mistaken.


Comment at: lib/Driver/Tools.cpp:6730
@@ -6729,1 +6729,3 @@
 CmdArgs.push_back("--64");
+  } else if (getToolChain().getTriple().getEnvironment() ==
+ llvm::Triple::GNUX32) {

Can you do this inside the x86_64 case?  Or is there a reason to make this its 
own case?


Comment at: lib/Driver/Tools.cpp:6928
@@ -6924,1 +6927,3 @@
 return "/lib64/ld-linux.so.2";
+  else if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUX32)
+return "/libx32/ld-linux-x32.so.2";

Can you extend this to check the arch?


Comment at: lib/Driver/Tools.cpp:7040
@@ -7034,1 +7039,3 @@
 CmdArgs.push_back("elf64_s390");
+  else if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUX32)
+CmdArgs.push_back("elf32_x86_64");

Here as well.

http://reviews.llvm.org/D4180



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r211227 - tests: relax ms-intrinsics test

2014-06-18 Thread Saleem Abdulrasool
On Wed, Jun 18, 2014 at 3:27 PM, Reid Kleckner  wrote:

> Oh man, the 'entry' block might be %0...  >_<
>

Yeah, I believe so.


> I didn't point this out in review because all the parameters retain their
> names in NDEBUG builds and nothing else is named.
>

Just threw me for a loop since I tested it with Debug+Asserts on
Linux-x86_64.


>
> On Wed, Jun 18, 2014 at 2:48 PM, Saleem Abdulrasool  > wrote:
>
>> Author: compnerd
>> Date: Wed Jun 18 16:48:44 2014
>> New Revision: 211227
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=211227&view=rev
>> Log:
>> tests: relax ms-intrinsics test
>>
>> Relax the tests to allow for differences between release and debug
>> builds.  This
>> should fix the buildbots.
>>
>> Thanks to Benjamin Kramer and Eric Christo for their invaluable tip that
>> this
>> was release build specific issue.
>>
>> Modified:
>> cfe/trunk/test/CodeGen/ms-intrinsics.c
>>
>> Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=211227&r1=211226&r2=211227&view=diff
>>
>> ==
>> --- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
>> +++ cfe/trunk/test/CodeGen/ms-intrinsics.c Wed Jun 18 16:48:44 2014
>> @@ -6,12 +6,11 @@ void *test_InterlockedExchangePointer(vo
>>  }
>>
>>  // CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** %Target,
>> i8* %Value){{.*}}{
>> -// CHECK: entry:
>> -// CHECK:   %0 = bitcast i8** %Target to i32*
>> -// CHECK:   %1 = ptrtoint i8* %Value to i32
>> -// CHECK:   %2 = atomicrmw xchg i32* %0, i32 %1 seq_cst
>> -// CHECK:   %3 = inttoptr i32 %2 to i8*
>> -// CHECK:   ret i8* %3
>> +// CHECK:   %[[TARGET:[0-9]+]] = bitcast i8** %Target to i32*
>> +// CHECK:   %[[VALUE:[0-9]+]] = ptrtoint i8* %Value to i32
>> +// CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %[[TARGET]], i32
>> %[[VALUE]] seq_cst
>> +// CHECK:   %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXCHANGE]] to i8*
>> +// CHECK:   ret i8* %[[RESULT]]
>>  // CHECK: }
>>
>>  void *test_InterlockedCompareExchangePointer(void * volatile
>> *Destination,
>> @@ -20,14 +19,13 @@ void *test_InterlockedCompareExchangePoi
>>  }
>>
>>  // CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8**
>> %Destination, i8* %Exchange, i8* %Comparand){{.*}}{
>> -// CHECK: entry:
>> -// CHECK:   %0 = bitcast i8** %Destination to i32*
>> -// CHECK:   %1 = ptrtoint i8* %Exchange to i32
>> -// CHECK:   %2 = ptrtoint i8* %Comparand to i32
>> -// CHECK:   %3 = cmpxchg volatile i32* %0, i32 %2, i32 %1 seq_cst seq_cst
>> -// CHECK:   %4 = extractvalue { i32, i1 } %3, 0
>> -// CHECK:   %5 = inttoptr i32 %4 to i8*
>> -// CHECK:   ret i8* %5
>> +// CHECK:   %[[DEST:[0-9]+]] = bitcast i8** %Destination to i32*
>> +// CHECK:   %[[EXCHANGE:[0-9]+]] = ptrtoint i8* %Exchange to i32
>> +// CHECK:   %[[COMPARAND:[0-9]+]] = ptrtoint i8* %Comparand to i32
>> +// CHECK:   %[[XCHG:[0-9]+]] = cmpxchg volatile i32* %[[DEST:[0-9]+]],
>> i32 %[[COMPARAND:[0-9]+]], i32 %[[EXCHANGE:[0-9]+]] seq_cst seq_cst
>> +// CHECK:   %[[EXTRACT:[0-9]+]] = extractvalue { i32, i1 } %[[XCHG]], 0
>> +// CHECK:   %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXTRACT]] to i8*
>> +// CHECK:   ret i8* %[[RESULT:[0-9]+]]
>>  // CHECK: }
>>
>>  long test_InterlockedExchange(long *Target, long Value) {
>> @@ -35,7 +33,6 @@ long test_InterlockedExchange(long *Targ
>>  }
>>
>>  // CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32
>> %Value){{.*}}{
>> -// CHECK: entry:
>> -// CHECK:   %0 = atomicrmw xchg i32* %Target, i32 %Value seq_cst
>> -// CHECK:   ret i32 %0
>> +// CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %Target, i32
>> %Value seq_cst
>> +// CHECK:   ret i32 %[[EXCHANGE:[0-9]+]]
>>  // CHECK: }
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] Use appropriate default PIE settings for OpenBSD

2014-06-18 Thread Brad Smith
This corrects the default PIE settings to match the behavior of our base
and ports GCC versions.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp(revision 211236)
+++ lib/Driver/Tools.cpp(working copy)
@@ -2429,6 +2429,27 @@
 }
   }
 
+  // OpenBSD-specific defaults for PIE
+  if (getToolChain().getTriple().getOS() == llvm::Triple::OpenBSD) {
+switch (getToolChain().getTriple().getArch()) {
+case llvm::Triple::mips64:
+case llvm::Triple::mips64el:
+case llvm::Triple::sparc:
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  IsPICLevelTwo = false; // "-fpie"
+  break;
+
+case llvm::Triple::ppc:
+case llvm::Triple::sparcv9:
+  IsPICLevelTwo = true; // "-fPIE"
+  break;
+
+default:
+  break;
+}
+  }
+
   // For the PIC and PIE flag options, this logic is different from the
   // legacy logic in very old versions of GCC, as that logic was just
   // a bug no one had ever fixed. This logic is both more rational and
Index: test/Driver/pic.c
===
--- test/Driver/pic.c   (revision 211236)
+++ test/Driver/pic.c   (working copy)
@@ -201,8 +201,18 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
 // On OpenBSD, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target amd64-pc-openbsd -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target i386-pc-openbsd -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target mips64-unknown-openbsd -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target mips64el-unknown-openbsd -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target powerpc-unknown-openbsd -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target sparc64-unknown-openbsd -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
 // RUN: %clang -c %s -target i386-pc-openbsd -fno-pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 //
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Teach CC1 to dump module dependencies to a directory

2014-06-18 Thread Justin Bogner
Ben Langmuir  writes:
> On Jun 18, 2014, at 9:11 AM, Argyrios Kyrtzidis 
> wrote:
>
> On Jun 18, 2014, at 1:08 AM, Justin Bogner 
> wrote:
>
> Thanks for the feedback!
>
> Argyrios Kyrtzidis  writes:
>
> Thank you for your work on this.
>
> Some high level comments first; the way ModuleDependencyCollector
> is
> getting hooked up, results in:
>
> - If no module needs building (because module cache has it) no
> module
> dependency is getting written out
>
> I realize this, but as far as I can tell there isn't really a
> practical
> way to get all of the module dependencies except for when we actually
> create a module. Unless there's a way to extract this information from
> an imported ModuleFile that I've missed, I think we need to collect
> this
> information as we parse the AST to build a module in the first place.
>
> If there is a more reliable way to do this, I'm all ears. I should
> mention though, for the purposes of getting more useful crash reports
> with modules this limitation isn't very important. Notably, it's
> useful
> to collect the .pcm files anyway, and using a fresh cache directory is
> a
> very simple way to do that.
>
> - It doesn’t hook in the top level module, e.g. if I have "@import
> Darwin;” then no module dependency is written out even if the
> module
> cache is empty.
>
> This seems like a bigger problem, and I don't really understand it.
> Where is the module built? I'm pretty convinced that the place I've
> hooked into is the only one that creates a CompilerInstance with
> BuildingModule set to true…
>
> Ben, could you help out on hooking up ModuleDependencyCollector in a way
> that will address the above ?
>
> Sure!  The problem is that the first time we come to attempt loading a
> top-level module (before it is compiled), we will be here and not attach
> anything since ModuleDepCollector hasn’t been filled in yet.
>
> +if (ModuleDepCollector)
> +  ModuleDepCollector->attachToASTReader(*ModuleManager);
>
> If you call ModuleDepCollector = getModuleDepCollector() before that if, it
> works for me.

Okay, since ModuleDepCollector needs to have the same lifetime as the
top-level CompilerInstance, it makes more sense to create it during
CreatePreprocessor along with the other DependencyOption stuff. This is
a bit nicer in that it makes getModuleDepCollector a bit less special,
but it does mean that this feature doesn't interoperate well with
-fdisable-free, which is unfortunate.

I've attached an updated patch. I've rolled the VFS map generation into
the main patch, as it didn't make much sense to do it separately. I've
also added some tests and added handling for path traversal (ie,
bin/../lib). Also attached an up to date patch for llvm implementing
copy_file.

What do you think?

>From 7b59b12f5b2341e354ebe60df828f302857181a0 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Mon, 12 May 2014 23:16:57 -0700
Subject: [PATCH] Frontend: Add a CC1 flag to dump module dependencies to a
 directory

This adds the -module-dependency-dir to clang -cc1, which specifies a
directory to copy all of a module's dependencies into in a form
suitable to be used as a VFS using -ivfsoverlay with the generated
vfs.yaml.

This is useful for crashdumps that involve modules, so that the module
dependencies will be intact when a crash report script is used to
reproduce a problem on another machine.

We currently encode the absolute path to the dump directory, due to
limitations in the VFS system. Until we can handle relative paths in
the VFS, users of the VFS map may need to run a simple search and
replace in the file.
---
 include/clang/Driver/Options.td  |   2 +
 include/clang/Frontend/CompilerInstance.h|   7 ++
 include/clang/Frontend/DependencyOutputOptions.h |   5 +-
 include/clang/Frontend/Utils.h   |  26 ++
 lib/Frontend/CMakeLists.txt  |   1 +
 lib/Frontend/CompilerInstance.cpp|  22 +
 lib/Frontend/CompilerInvocation.cpp  |   2 +
 lib/Frontend/ModuleDependencyCollector.cpp   | 111 +++
 test/Modules/dependency-dump-dependent-module.m  |  24 +
 test/Modules/dependency-dump.m   |  22 +
 10 files changed, 221 insertions(+), 1 deletion(-)
 create mode 100644 lib/Frontend/ModuleDependencyCollector.cpp
 create mode 100644 test/Modules/dependency-dump-dependent-module.m
 create mode 100644 test/Modules/dependency-dump.m

diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 85f2e0c..dd8722e 100644
--- a/include/clang/Driver/Options.td
+++ b

[PATCH] [RFC] Print exact source locations of global variables in ASan error reports.

2014-06-18 Thread Alexey Samsonov
Hi kcc, eugenis,

This changes introduces llvm.asan.globals metadata, which can be
used by the frontend to provide additional information about the LLVM
global variables, namely:
1) source location (file/line/column) of corresponding globals in the user code.
These locations will be available at runtime, and will be printed in the
error report if needed, even if the binary is built without debug info.
2) whether global is dynamically initialized. This replaces
llvm.asan.dynamically_initialized_globals metadata used to detect init-order 
bugs.
3) whether the global is blacklisted. This is a first step to move all blacklist
functionality to the frontend.

Note: This is an ABI-breaking change. All users of ASan runtime library will 
have
to emit new layout of __asan_global structure (now it has one more field).

If you're OK with this change, I will commit it with extra ASan output tests,
checking that we're actually reporting source locations for global variables,
function-static variables and simple string literals.

http://reviews.llvm.org/D4203

Files:
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  projects/compiler-rt/lib/asan/asan_interface_internal.h
  projects/compiler-rt/lib/asan/asan_report.cc
  test/Instrumentation/AddressSanitizer/instrument_global.ll
  test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
  tools/clang/lib/CodeGen/CGDecl.cpp
  tools/clang/lib/CodeGen/CodeGenModule.cpp
  tools/clang/lib/CodeGen/CodeGenModule.h
  tools/clang/test/CodeGen/sanitize-init-order.cpp
Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
@@ -215,28 +216,88 @@
   "Number of optimized accesses to global vars");
 
 namespace {
-/// A set of dynamically initialized globals extracted from metadata.
-class SetOfDynamicallyInitializedGlobals {
+/// Frontend-provided metadata for global variables.
+class GlobalsMetadata {
  public:
-  void Init(Module& M) {
-// Clang generates metadata identifying all dynamically initialized globals.
-NamedMDNode *DynamicGlobals =
-M.getNamedMetadata("llvm.asan.dynamically_initialized_globals");
-if (!DynamicGlobals)
+  void init(Module& M) {
+assert(!inited_);
+inited_ = true;
+NamedMDNode *Globals = M.getNamedMetadata("llvm.asan.globals");
+if (!Globals)
   return;
-for (const auto MDN : DynamicGlobals->operands()) {
-  assert(MDN->getNumOperands() == 1);
-  Value *VG = MDN->getOperand(0);
-  // The optimizer may optimize away a global entirely, in which case we
-  // cannot instrument access to it.
-  if (!VG)
+for (auto MDN : Globals->operands()) {
+  // Format of the metadata node for the global:
+  // {
+  //   global,
+  //   source_location,
+  //   i1 is_dynamically_initialized,
+  //   i1 is_blacklisted
+  // }
+  assert(MDN->getNumOperands() == 4);
+  Value *V = MDN->getOperand(0);
+  // The optimizer may optimize away a global entirely.
+  if (!V)
 continue;
-  DynInitGlobals.insert(cast(VG));
+  GlobalVariable *GV = cast(V);
+  // We may already know the source location for GV, if it was merged
+  // with another global.
+  if (!SourceLocation.count(GV)) {
+if (Value *Loc = MDN->getOperand(1)) {
+  GlobalVariable *GVLoc = cast(Loc);
+  SourceLocation[GV] = GVLoc;
+  addSourceLocationGlobal(GVLoc);
+}
+  }
+  ConstantInt *IsDynInit = cast(MDN->getOperand(2));
+  if (IsDynInit->isOne())
+DynInitGlobals.insert(GV);
+  ConstantInt *IsBlacklisted = cast(MDN->getOperand(3));
+  if (IsBlacklisted->isOne())
+BlacklistedGlobals.insert(GV);
 }
   }
-  bool Contains(GlobalVariable *G) { return DynInitGlobals.count(G) != 0; }
+
+  GlobalVariable *getSourceLocation(GlobalVariable *G) const {
+auto Pos = SourceLocation.find(G);
+return (Pos != SourceLocation.end()) ? Pos->second : nullptr;
+  }
+
+  /// Check if the global is dynamically initialized.
+  bool isDynInit(GlobalVariable *G) const {
+return DynInitGlobals.count(G);
+  }
+
+  /// Check if the global was blacklisted.
+  bool isBlacklisted(GlobalVariable *G) const {
+return BlacklistedGlobals.count(G);
+  }
+
+  /// Check if the global was generated to describe source location of another
+  /// global (we don't want to instrument them).
+  bool isSourceLocationGlobal(GlobalVariable *G) const {
+return LocationGlobals.count(G);
+  }
+
  private:
-  SmallSet DynInitGlobals;
+  bool inited_ = false;
+  DenseM

Re: Add Rpass-missed and Rpass-analysis reports to the loop vectorizer

2014-06-18 Thread Tyler Nowicki
Hi Zinovy, Arnold,Thanks for the reviews!Here is an updated patch. The tests included do not test every diagnostic message that can be produced. To do this I am modifying the existing vectorization tests. I would like to split that off as a separate patch. I am going through all the tests right now. Some of them need to be fixed as well because they are not failing where they were intended to fail.Let me know what you think.Tyler


vectorization_diagnostics_core-svn.patch
Description: Binary data
On Jun 14, 2014, at 7:55 AM, Zinovy Nis  wrote:Nice work!Could you please print Hints.forced flag to see how many forced loops (#pragma omp simd / vectorize) were still not vectorized.
2014-06-11 2:13 GMT+04:00 Tyler Nowicki :
Hi Diego, Arnold,

Here is a patch for adding Rpass-missed and Rpass-analysis reports to the loop vectorizer. To check that the correct analysis is reported I am using the existing loop vectorization tests. I haven’t updated all of the tests yet because I wanted to make sure I was on the right path.


Let me know what you think.

Tyler

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211248 - DiagnoseUnknownTypename always emits a diagnostic and returns true

2014-06-18 Thread Reid Kleckner
Author: rnk
Date: Wed Jun 18 20:23:22 2014
New Revision: 211248

URL: http://llvm.org/viewvc/llvm-project?rev=211248&view=rev
Log:
DiagnoseUnknownTypename always emits a diagnostic and returns true

Make it return void and delete the dead code in the parser that handled
the case where it might return false.  This has been dead since 2010
when John deleted Action.h.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=211248&r1=211247&r2=211248&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Jun 18 20:23:22 
2014
@@ -333,8 +333,6 @@ def warn_vector_long_decl_spec_combinati
   "Use of 'long' with '__vector' is deprecated">, InGroup;
 def err_friend_invalid_in_context : Error<
   "'friend' used outside of class">;
-def err_unknown_typename : Error<
-  "unknown type name %0">;
 def err_use_of_tag_name_without_tag : Error<
   "must use '%1' tag to refer to type %0%select{| in this scope}2">;
 def err_templated_using_directive : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=211248&r1=211247&r2=211248&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 18 20:23:22 
2014
@@ -6828,6 +6828,8 @@ def warn_direct_ivar_access : Warning<"i
   "directly accessed">, InGroup>, 
DefaultIgnore;
 
 // Spell-checking diagnostics
+def err_unknown_typename : Error<
+  "unknown type name %0">;
 def err_unknown_type_or_class_name_suggest : Error<
   "unknown %select{type|class}1 name %0; did you mean %2?">;
 def err_unknown_typename_suggest : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=211248&r1=211247&r2=211248&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jun 18 20:23:22 2014
@@ -1408,7 +1408,7 @@ public:
  IdentifierInfo **CorrectedII = nullptr);
   TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
   bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
-  bool DiagnoseUnknownTypeName(IdentifierInfo *&II,
+  void DiagnoseUnknownTypeName(IdentifierInfo *&II,
SourceLocation IILoc,
Scope *S,
CXXScopeSpec *SS,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=211248&r1=211247&r2=211248&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Jun 18 20:23:22 2014
@@ -2170,42 +2170,33 @@ bool Parser::ParseImplicitInt(DeclSpec &
 }
   }
 
-  // This is almost certainly an invalid type name. Let the action emit a
-  // diagnostic and attempt to recover.
+  // This is almost certainly an invalid type name. Let Sema emit a diagnostic
+  // and attempt to recover.
   ParsedType T;
   IdentifierInfo *II = Tok.getIdentifierInfo();
-  if (Actions.DiagnoseUnknownTypeName(II, Loc, getCurScope(), SS, T,
-  getLangOpts().CPlusPlus &&
-  NextToken().is(tok::less))) {
-// The action emitted a diagnostic, so we don't have to.
-if (T) {
-  // The action has suggested that the type T could be used. Set that as
-  // the type in the declaration specifiers, consume the would-be type
-  // name token, and we're done.
-  const char *PrevSpec;
-  unsigned DiagID;
-  DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T,
- Actions.getASTContext().getPrintingPolicy());
-  DS.SetRangeEnd(Tok.getLocation());
-  ConsumeToken();
-  // There may be other declaration specifiers after this.
-  return true;
-} else if (II != Tok.getIdentifierInfo()) {
-  // If no type was suggested, the correction is to a keyword
-  Tok.setKind(II->getTokenID());
-  // There may be other declaration specifiers after this.
-  return true;
-}
-
-// Fall through; the action had no suggestion for us.
-  } else {
-// The action did

[clang-tools-extra] r211245 - Unbreak the build after r211244.

2014-06-18 Thread David Blaikie
Author: dblaikie
Date: Wed Jun 18 19:43:19 2014
New Revision: 211245

URL: http://llvm.org/viewvc/llvm-project?rev=211245&view=rev
Log:
Unbreak the build after r211244.

These operator overloads were unneeded (once the const correctness in
PooledStringPtr was corrected) and inefficient (since the strings are
pooled the pointers can just be compared for equality instead of doing
strcmp).

Modified:
clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp

Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=211245&r1=211244&r2=211245&view=diff
==
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Wed Jun 18 
19:43:19 2014
@@ -535,19 +535,6 @@ ConditionValueKindStrings[] = {
   "(not evaluated)", "false", "true"
 };
 
-// We need some operator overloads for string handles.
-bool operator==(const StringHandle &H1, const StringHandle &H2) {
-  const char *S1 = (H1 ? *H1 : "");
-  const char *S2 = (H2 ? *H2 : "");
-  int Diff = strcmp(S1, S2);
-  return Diff == 0;
-}
-bool operator!=(const StringHandle &H1, const StringHandle &H2) {
-  const char *S1 = (H1 ? *H1 : "");
-  const char *S2 = (H2 ? *H2 : "");
-  int Diff = strcmp(S1, S2);
-  return Diff != 0;
-}
 bool operator<(const StringHandle &H1, const StringHandle &H2) {
   const char *S1 = (H1 ? *H1 : "");
   const char *S2 = (H2 ? *H2 : "");


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] Use the newly added FindInEnvPath helper in clang

2014-06-18 Thread Ehsan Akhgari
Hi hans,

http://reviews.llvm.org/D4202

Files:
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -932,30 +932,9 @@
 /// \brief Check whether the file referenced by Value exists in the LIB
 /// environment variable.
 static bool ExistsInLibDir(StringRef Value) {
-  llvm::Optional OptPath = llvm::sys::Process::GetEnv("LIB");
-  if (!OptPath.hasValue())
-return false;
-
-#ifdef LLVM_ON_WIN32
-  const StringRef PathSeparators = ";";
-#else
-  const StringRef PathSeparators = ":";
-#endif
-
-  SmallVector LibDirs;
-  llvm::SplitString(OptPath.getValue(), LibDirs, PathSeparators);
-
-  for (const auto &LibDir : LibDirs) {
-if (LibDir.empty())
-  continue;
-
-SmallString<128> FilePath(LibDir);
-llvm::sys::path::append(FilePath, Value);
-if (llvm::sys::fs::exists(Twine(FilePath)))
-  return true;
-  }
-
-  return false;
+  llvm::Optional FilePath =
+llvm::sys::FindInEnvPath("LIB", Value);
+  return FilePath.hasValue();
 }
 
 /// \brief Check that the file referenced by Value exists. If it doesn't,
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7532,30 +7532,13 @@
 // if it's available as cl.exe on the path.
 static std::string FindFallback(const char *FallbackName,
 const char *ClangProgramPath) {
-  llvm::Optional OptPath = llvm::sys::Process::GetEnv("PATH");
-  if (!OptPath.hasValue())
-return FallbackName;
+  llvm::Optional FilePath =
+llvm::sys::FindInEnvPath("PATH", FallbackName);
 
-#ifdef LLVM_ON_WIN32
-  const StringRef PathSeparators = ";";
-#else
-  const StringRef PathSeparators = ":";
-#endif
-
-  SmallVector PathSegments;
-  llvm::SplitString(OptPath.getValue(), PathSegments, PathSeparators);
-
-  for (size_t i = 0, e = PathSegments.size(); i != e; ++i) {
-const StringRef &PathSegment = PathSegments[i];
-if (PathSegment.empty())
-  continue;
-
-SmallString<128> FilePath(PathSegment);
-llvm::sys::path::append(FilePath, FallbackName);
-if (llvm::sys::fs::can_execute(Twine(FilePath)) &&
-!llvm::sys::fs::equivalent(Twine(FilePath), ClangProgramPath))
-  return FilePath.str();
-  }
+  if (FilePath.hasValue() &&
+  llvm::sys::fs::can_execute(Twine(FilePath.getValue())) &&
+  !llvm::sys::fs::equivalent(Twine(FilePath.getValue()), ClangProgramPath))
+return FilePath.getValue();
 
   return FallbackName;
 }
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -932,30 +932,9 @@
 /// \brief Check whether the file referenced by Value exists in the LIB
 /// environment variable.
 static bool ExistsInLibDir(StringRef Value) {
-  llvm::Optional OptPath = llvm::sys::Process::GetEnv("LIB");
-  if (!OptPath.hasValue())
-return false;
-
-#ifdef LLVM_ON_WIN32
-  const StringRef PathSeparators = ";";
-#else
-  const StringRef PathSeparators = ":";
-#endif
-
-  SmallVector LibDirs;
-  llvm::SplitString(OptPath.getValue(), LibDirs, PathSeparators);
-
-  for (const auto &LibDir : LibDirs) {
-if (LibDir.empty())
-  continue;
-
-SmallString<128> FilePath(LibDir);
-llvm::sys::path::append(FilePath, Value);
-if (llvm::sys::fs::exists(Twine(FilePath)))
-  return true;
-  }
-
-  return false;
+  llvm::Optional FilePath =
+llvm::sys::FindInEnvPath("LIB", Value);
+  return FilePath.hasValue();
 }
 
 /// \brief Check that the file referenced by Value exists. If it doesn't,
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7532,30 +7532,13 @@
 // if it's available as cl.exe on the path.
 static std::string FindFallback(const char *FallbackName,
 const char *ClangProgramPath) {
-  llvm::Optional OptPath = llvm::sys::Process::GetEnv("PATH");
-  if (!OptPath.hasValue())
-return FallbackName;
+  llvm::Optional FilePath =
+llvm::sys::FindInEnvPath("PATH", FallbackName);
 
-#ifdef LLVM_ON_WIN32
-  const StringRef PathSeparators = ";";
-#else
-  const StringRef PathSeparators = ":";
-#endif
-
-  SmallVector PathSegments;
-  llvm::SplitString(OptPath.getValue(), PathSegments, PathSeparators);
-
-  for (size_t i = 0, e = PathSegments.size(); i != e; ++i) {
-const StringRef &PathSegment = PathSegments[i];
-if (PathSegment.empty())
-  continue;
-
-SmallString<128> FilePath(PathSegment);
-llvm::sys::path::append(FilePath, FallbackName);
-if (llvm::sys::fs::can_execute(Twine(FilePath)) &&
-!llvm::sys::fs::equivalent(Twine(FilePath), ClangProgramPath))
-  return FilePath.str();
-  }
+  if (FilePath.hasValue() &&
+  llvm::sys::fs::can_execute(Twine(FilePath.getValue())) &&
+   

r211243 - Objective-C ARC. Allow conversion of (void*) pointers to

2014-06-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Wed Jun 18 18:52:49 2014
New Revision: 211243

URL: http://llvm.org/viewvc/llvm-project?rev=211243&view=rev
Log:
Objective-C ARC. Allow conversion of (void*) pointers to
retainable ObjC pointers without requiring a bridge-cast
in the context of pointer comparison as this is in effect 
a +0 context. // rdar://16627903

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=211243&r1=211242&r2=211243&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jun 18 18:52:49 2014
@@ -7820,7 +7820,9 @@ public:
   ARCConversionResult CheckObjCARCConversion(SourceRange castRange,
  QualType castType, Expr *&op,
  CheckedConversionKind CCK,
- bool DiagnoseCFAudited = false);
+ bool DiagnoseCFAudited = false,
+ BinaryOperatorKind Opc = 
BO_PtrMemD
+ );
 
   Expr *stripARCUnbridgedCast(Expr *e);
   void diagnoseARCUnbridgedCast(Expr *e);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=211243&r1=211242&r2=211243&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jun 18 18:52:49 2014
@@ -8149,7 +8149,8 @@ QualType Sema::CheckCompareOperands(Expr
   else {
 Expr *E = RHS.get();
 if (getLangOpts().ObjCAutoRefCount)
-  CheckObjCARCConversion(SourceRange(), LHSType, E, 
CCK_ImplicitConversion);
+  CheckObjCARCConversion(SourceRange(), LHSType, E, 
CCK_ImplicitConversion, false,
+ Opc);
 RHS = ImpCastExprToType(E, LHSType,
 LPT ? CK_BitCast 
:CK_CPointerToObjCPointerCast);
   }

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=211243&r1=211242&r2=211243&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jun 18 18:52:49 2014
@@ -3624,7 +3624,8 @@ Sema::CheckObjCBridgeRelatedConversions(
 Sema::ARCConversionResult
 Sema::CheckObjCARCConversion(SourceRange castRange, QualType castType,
  Expr *&castExpr, CheckedConversionKind CCK,
- bool DiagnoseCFAudited) {
+ bool DiagnoseCFAudited,
+ BinaryOperatorKind Opc) {
   QualType castExprType = castExpr->getType();
 
   // For the purposes of the classification, we assume reference types
@@ -3718,8 +3719,10 @@ Sema::CheckObjCARCConversion(SourceRange
   // instead.
   if (!DiagnoseCFAudited || exprACTC != ACTC_retainable ||
   castACTC != ACTC_coreFoundation)
-diagnoseObjCARCConversion(*this, castRange, castType, castACTC,
-  castExpr, castExpr, exprACTC, CCK);
+if (!(exprACTC == ACTC_voidPtr && castACTC == ACTC_retainable &&
+  (Opc == BO_NE || Opc == BO_EQ)))
+  diagnoseObjCARCConversion(*this, castRange, castType, castACTC,
+castExpr, castExpr, exprACTC, CCK);
   return ACR_okay;
 }
 

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=211243&r1=211242&r2=211243&view=diff
==
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Wed Jun 18 18:52:49 2014
@@ -285,7 +285,7 @@ void test11(id op, void *vp) {
   b = (nil == vp);
 
   b = (vp == op); // expected-error {{implicit conversion of Objective-C 
pointer type 'id' to C pointer type 'void *' requires a bridged cast}} 
expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
-  b = (op == vp); // expected-error {{implicit conversion of C pointer type 
'void *' to Objective-C pointer type 'id' requires a bridged cast}} 
expected-note {{use __bridge}} expected-note {{use CFBridgingRelease call}}
+  b = (op == vp);
 }
 
 void test12(id collection) {
@@ -782,3 +782,19 @@ void foo(NSArray *array) {
 }
   }
 }
+
+// rdar://16627903
+extern void abort();
+#define TKAssertEqual(a, b) do{\
+__typeof(a) a_res = (a);\
+__typeof(b) b_res = (b);\
+if ((a_res) != (b_res)) {\
+abort();\
+}\
+}while

Re: r210936 - Copy the documentation of -fstandalone-debug from the man page to the user

2014-06-18 Thread Adrian Prantl

> On Jun 15, 2014, at 1:07 PM, Alp Toker  wrote:
> 
> 
> On 14/06/2014 00:12, Adrian Prantl wrote:
>> Author: adrian
>> Date: Fri Jun 13 16:12:31 2014
>> New Revision: 210936
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=210936&view=rev
>> Log:
>> Copy the documentation of -fstandalone-debug from the man page to the user
>> manual.
> 
> Hi Adrian,
> 
> It bothers me that we now have two copies of this documentation in-tree.
> 
> There are readily available tools to generate man pages from rst files. The 
> cost of hooking a doc tool up to the build system is certainly lower than 
> having skilled compiler engineers maintain two divergent copies of the 
> documentation (history shows we have a hard enough time maintaining a single 
> set of quality docs, let alone two).
> 
> Do you have a timeline to remove one of the duplicate copies?

Hi Alp,

I think this is a reasonable suggestion, but after comparing the user manual 
and the man page, I’m unsure what the best way to proceed here is. There 
obviously is some overlap between user manual and man page, and we might be 
able to extract a common core that is shared between user manual and man page 
and automatically inserted into both at documentation build time. But the man 
page can also be seen as a condensed version of the user manual that only 
briefly lists all the options and everything that is necessary to invoke the 
various tools on the command line, and form that point of view, it is not clear 
whether it is even desirable to unify those two texts.

-- adrian

> 
> Alp.
> 
> 
> 
>> 
>> rdar://problem/17307006
>> 
>> Modified:
>> cfe/trunk/docs/UsersManual.rst
>> 
>> Modified: cfe/trunk/docs/UsersManual.rst
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=210936&r1=210935&r2=210936&view=diff
>> ==
>> --- cfe/trunk/docs/UsersManual.rst (original)
>> +++ cfe/trunk/docs/UsersManual.rst Fri Jun 13 16:12:31 2014
>> @@ -1298,6 +1298,22 @@ below. If multiple flags are present, th
>>doesn't contain any other data (e.g. description of local variables or
>>function parameters).
>>  +.. option:: -fstandalone-debug -fno-standalone-debug
>> +
>> +  Clang supports a number of optimizations to reduce the size of debug
>> +  information in the binary. They work based on the assumption that
>> +  the debug type information can be spread out over multiple
>> +  compilation units.  For instance, Clang will not emit type
>> +  definitions for types that are not needed by a module and could be
>> +  replaced with a forward declaration.  Further, Clang will only emit
>> +  type info for a dynamic C++ class in the module that contains the
>> +  vtable for the class.
>> +
>> +  The ``-fstandalone-debug`` option turns off these optimizations.
>> +  This is useful when working with 3rd-party libraries that don't come
>> +  with debug information.  Note that Clang will never emit type
>> +  information for types that are not referenced at all by the program.
>> +
>>  .. option:: -g
>>  Generate complete debug info.
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> -- 
> http://www.nuanti.com
> the browser experts


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Sema: Static redeclaration after extern declarations is a Microsoft Extension

2014-06-18 Thread David Majnemer
Closed by commit rL211238 (authored by @majnemer).

http://reviews.llvm.org/D4149

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Misc/warning-flags.c
  cfe/trunk/test/Sema/private-extern.c
  cfe/trunk/test/Sema/tentative-decls.c
  cfe/trunk/test/Sema/thread-specifier.c
  cfe/trunk/test/Sema/var-redecl.c
  cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
Index: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
===
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
@@ -144,11 +144,14 @@
 void static_func(); // expected-note {{previous declaration is here}}
 
 
-static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
+static void static_func() // expected-warning {{redeclaring non-static 'static_func' as static is a Microsoft extension}}
 {
 
 }
 
+extern const int static_var; // expected-note {{previous declaration is here}}
+static const int static_var = 3; // expected-warning {{redeclaring non-static 'static_var' as static is a Microsoft extension}}
+
 long function_prototype(int a);
 long (*function_ptr)(int a);
 
Index: cfe/trunk/test/Sema/tentative-decls.c
===
--- cfe/trunk/test/Sema/tentative-decls.c
+++ cfe/trunk/test/Sema/tentative-decls.c
@@ -23,7 +23,7 @@
 int i1 = 2; // expected-error {{redefinition of 'i1'}}
 int i1;
 int i1;
-extern int i5; // expected-note {{previous definition is here}}
+extern int i5; // expected-note {{previous declaration is here}}
 static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}}
 
 static int i2 = 5; // expected-note 1 {{previous definition is here}}
@@ -49,7 +49,7 @@
 int redef[11]; // expected-error{{redefinition of 'redef'}}
 
 void func() {
-  extern int i6; // expected-note {{previous definition is here}}
+  extern int i6; // expected-note {{previous declaration is here}}
   static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
 }
 
Index: cfe/trunk/test/Sema/private-extern.c
===
--- cfe/trunk/test/Sema/private-extern.c
+++ cfe/trunk/test/Sema/private-extern.c
@@ -13,10 +13,10 @@
 int g3; // expected-note{{previous definition}}
 static int g3; // expected-error{{static declaration of 'g3' follows non-static declaration}}
 
-extern int g4; // expected-note{{previous definition}}
+extern int g4; // expected-note{{previous declaration}}
 static int g4; // expected-error{{static declaration of 'g4' follows non-static declaration}}
 
-__private_extern__ int g5; // expected-note{{previous definition}}
+__private_extern__ int g5; // expected-note{{previous declaration}}
 static int g5; // expected-error{{static declaration of 'g5' follows non-static declaration}}
 
 void f0() {
@@ -30,12 +30,12 @@
 }
 
 void f2() {
-  extern int g8; // expected-note{{previous definition}}
+  extern int g8; // expected-note{{previous declaration}}
   int g8; // expected-error {{non-extern declaration of 'g8' follows extern declaration}}
 }
 
 void f3() {
-  __private_extern__ int g9; // expected-note{{previous definition}}
+  __private_extern__ int g9; // expected-note{{previous declaration}}
   int g9; // expected-error {{non-extern declaration of 'g9' follows extern declaration}}
 }
 
Index: cfe/trunk/test/Sema/var-redecl.c
===
--- cfe/trunk/test/Sema/var-redecl.c
+++ cfe/trunk/test/Sema/var-redecl.c
@@ -58,5 +58,5 @@
 
 // PR3645
 static int a;
-extern int a; // expected-note {{previous definition is here}}
+extern int a; // expected-note {{previous declaration is here}}
 int a;	// expected-error {{non-static declaration of 'a' follows static declaration}}
Index: cfe/trunk/test/Sema/thread-specifier.c
===
--- cfe/trunk/test/Sema/thread-specifier.c
+++ cfe/trunk/test/Sema/thread-specifier.c
@@ -58,7 +58,7 @@
 }
 
 __thread typedef int t14; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local|thread_local}}' declaration specifier}}
-__thread int t15; // expected-note {{previous declaration is here}}
+__thread int t15; // expected-note {{previous definition is here}}
 extern int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
 extern int t16; // expected-note {{previous declaration is here}}
 __thread int t16; // expected-error {{thread-local declaration of 't16' follows non-thread-local declaration}}
Index: cfe/trunk/test/Misc/warning-flags.c
===
--- cfe/trunk/test/Misc/warning-flags.c
+++ cfe/trunk/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER g

r211238 - Sema: Static redeclaration after extern declarations is a Microsoft Extension

2014-06-18 Thread David Majnemer
Author: majnemer
Date: Wed Jun 18 18:26:25 2014
New Revision: 211238

URL: http://llvm.org/viewvc/llvm-project?rev=211238&view=rev
Log:
Sema: Static redeclaration after extern declarations is a Microsoft Extension

CL permits static redeclarations to follow extern declarations.  The
storage specifier on the latter declaration has no effect.

This fixes PR20034.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Misc/warning-flags.c
cfe/trunk/test/Sema/private-extern.c
cfe/trunk/test/Sema/tentative-decls.c
cfe/trunk/test/Sema/thread-specifier.c
cfe/trunk/test/Sema/var-redecl.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=211238&r1=211237&r2=211238&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 18 18:26:25 
2014
@@ -3814,8 +3814,8 @@ def note_extern_c_global_conflict : Note
   "declared %select{in global scope|with C language linkage}0 here">;
 def warn_weak_import : Warning <
   "an already-declared variable is made a weak_import declaration %0">;
-def warn_static_non_static : ExtWarn<
-  "static declaration of %0 follows non-static declaration">;
+def ext_static_non_static : Extension<
+  "redeclaring non-static %0 as static is a Microsoft extension">, 
InGroup;
 def err_non_static_static : Error<
   "non-static declaration of %0 follows static declaration">;
 def err_extern_non_extern : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=211238&r1=211237&r2=211238&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jun 18 18:26:25 2014
@@ -2253,6 +2253,24 @@ Sema::CXXSpecialMember Sema::getSpecialM
   return Sema::CXXInvalid;
 }
 
+// Determine whether the previous declaration was a definition, implicit
+// declaration, or a declaration.
+template 
+static std::pair
+getNoteDiagForInvalidRedeclaration(const T *Old, const T *New) {
+  diag::kind PrevDiag;
+  SourceLocation OldLocation = Old->getLocation();
+  if (Old->isThisDeclarationADefinition())
+PrevDiag = diag::note_previous_definition;
+  else if (Old->isImplicit()) {
+PrevDiag = diag::note_previous_implicit_declaration;
+if (OldLocation.isInvalid())
+  OldLocation = New->getLocation();
+  } else
+PrevDiag = diag::note_previous_declaration;
+  return std::make_pair(PrevDiag, OldLocation);
+}
+
 /// canRedefineFunction - checks if a function can be redefined. Currently,
 /// only extern inline functions can be redefined, and even then only in
 /// GNU89 mode.
@@ -2345,18 +2363,10 @@ bool Sema::MergeFunctionDecl(FunctionDec
   if (Old->isInvalidDecl())
 return true;
 
-  // Determine whether the previous declaration was a definition,
-  // implicit declaration, or a declaration.
   diag::kind PrevDiag;
-  SourceLocation OldLocation = Old->getLocation();
-  if (Old->isThisDeclarationADefinition())
-PrevDiag = diag::note_previous_definition;
-  else if (Old->isImplicit()) {
-PrevDiag = diag::note_previous_implicit_declaration;
-if (OldLocation.isInvalid())
-  OldLocation = New->getLocation();
-  } else
-PrevDiag = diag::note_previous_declaration;
+  SourceLocation OldLocation;
+  std::tie(PrevDiag, OldLocation) =
+  getNoteDiagForInvalidRedeclaration(Old, New);
 
   // Don't complain about this if we're in GNU89 mode and the old function
   // is an extern inline function.
@@ -2368,7 +2378,7 @@ bool Sema::MergeFunctionDecl(FunctionDec
   !New->getTemplateSpecializationInfo() &&
   !canRedefineFunction(Old, getLangOpts())) {
 if (getLangOpts().MicrosoftExt) {
-  Diag(New->getLocation(), diag::warn_static_non_static) << New;
+  Diag(New->getLocation(), diag::ext_static_non_static) << New;
   Diag(OldLocation, PrevDiag);
 } else {
   Diag(New->getLocation(), diag::err_static_non_static) << New;
@@ -3069,13 +3079,25 @@ void Sema::MergeVarDecl(VarDecl *New, Lo
   if (New->isInvalidDecl())
 return;
 
+  diag::kind PrevDiag;
+  SourceLocation OldLocation;
+  std::tie(PrevDiag, OldLocation) =
+  getNoteDiagForInvalidRedeclaration(Old, New);
+
   // [dcl.stc]p8: Check if we have a non-static decl followed by a static.
   if (New->getStorageClass() == SC_Static &&
   !New->isStaticDataMember() &&
   Old->hasExternalFormalLinkage()) {
-Diag(New->getLocation(), diag::err_static_non_static) << 
New->getDeclName();
-Diag(Old->getLocation(), diag::note_previous_definition);
-return New->se

r211237 - Objective-C. Revert my patch in r211234.

2014-06-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Wed Jun 18 18:22:38 2014
New Revision: 211237

URL: http://llvm.org/viewvc/llvm-project?rev=211237&view=rev
Log:
Objective-C. Revert my patch in r211234.


Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/ARCMT/checking.m
cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result
cfe/trunk/test/SemaObjC/arc-type-conversion.m
cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=211237&r1=211236&r2=211237&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jun 18 18:22:38 2014
@@ -3168,9 +3168,7 @@ diagnoseObjCARCConversion(Sema &S, Sourc
   if ((castACTC == ACTC_coreFoundation &&  exprACTC == ACTC_retainable &&
ObjCBridgeRelatedAttrFromType(castType, TDNDecl)) ||
   (exprACTC == ACTC_coreFoundation && castACTC == ACTC_retainable &&
-   ObjCBridgeRelatedAttrFromType(castExprType, TDNDecl)) ||
-  (exprACTC ==ACTC_voidPtr && castACTC == ACTC_retainable &&
-   CCK == Sema::CCK_ImplicitConversion))
+   ObjCBridgeRelatedAttrFromType(castExprType, TDNDecl)))
 return;
   
   unsigned srcKind = 0;

Modified: cfe/trunk/test/ARCMT/checking.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=211237&r1=211236&r2=211237&view=diff
==
--- cfe/trunk/test/ARCMT/checking.m (original)
+++ cfe/trunk/test/ARCMT/checking.m Wed Jun 18 18:22:38 2014
@@ -158,8 +158,8 @@ void * cvt(id arg)
   (void)(__autoreleasing id**)voidp_val;
   (void)(void*)voidp_val;
   (void)(void**)arg; // expected-error {{disallowed}}
-  cvt((void*)arg); // expected-error 1 {{requires a bridged cast}} \
-   // expected-note 1 {{use __bridge to}} expected-note {{use 
CFBridgingRetain call}}
+  cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \
+   // expected-note 2 {{use __bridge to}} expected-note {{use 
CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}}
   cvt(0);
   (void)(__strong id**)(0);
   return arg; // expected-error {{requires a bridged cast}} expected-note 
{{use __bridge}} expected-note {{use CFBridgingRetain call}}

Modified: cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result?rev=211237&r1=211236&r2=211237&view=diff
==
--- cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result (original)
+++ cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result Wed Jun 18 18:22:38 2014
@@ -36,7 +36,7 @@ void f(BOOL b, id p) {
   CFUUIDRef   _uuid;
   NSString *_uuidString = (NSString 
*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
   _uuidString = (NSString 
*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
-  _uuidString = CFRetain(_uuid);
+  _uuidString = CFBridgingRelease(CFRetain(_uuid));
 }
 
 @implementation NSString (StrExt)

Modified: cfe/trunk/test/SemaObjC/arc-type-conversion.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-type-conversion.m?rev=211237&r1=211236&r2=211237&view=diff
==
--- cfe/trunk/test/SemaObjC/arc-type-conversion.m (original)
+++ cfe/trunk/test/SemaObjC/arc-type-conversion.m Wed Jun 18 18:22:38 2014
@@ -16,8 +16,10 @@ void * cvt(id arg)
   (void)(void*)voidp_val;
   (void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 
'void **' is disallowed with ARC}}
   cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' 
to C pointer type 'void *' requires a bridged cast}} \
-   // expected-note 1 {{use __bridge to convert directly (no 
change in ownership)}} \
+   // expected-error {{implicit conversion of C pointer type 
'void *' to Objective-C pointer type 'id' requires a bridged cast}} \
+   // expected-note 2 {{use __bridge to convert directly (no 
change in ownership)}} \
// expected-note {{use CFBridgingRetain call to make an ARC 
object available as a +1 'void *'}} \
+   // expected-note {{use CFBridgingRelease call to transfer 
ownership of a +1 'void *' into ARC}}
   cvt(0);
   (void)(__strong id**)(0);
   return arg; // expected-error {{implicit conversion of Objective-C pointer 
type 'id' to C pointer type 'void *' requires a bridged cast}} \

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=211237&r1=211236&r2=211237&view=diff
==
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test

r211234 - Objective-C ARC. Allow conversion of (void*) pointers to

2014-06-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Wed Jun 18 17:50:40 2014
New Revision: 211234

URL: http://llvm.org/viewvc/llvm-project?rev=211234&view=rev
Log:
Objective-C ARC. Allow conversion of (void*) pointers to
retainable ObjC pointers without requiring a bridge-cast
by recognizing this as a +0 context. // rdar://16627903

Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/ARCMT/checking.m
cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result
cfe/trunk/test/SemaObjC/arc-type-conversion.m
cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=211234&r1=211233&r2=211234&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jun 18 17:50:40 2014
@@ -3168,7 +3168,9 @@ diagnoseObjCARCConversion(Sema &S, Sourc
   if ((castACTC == ACTC_coreFoundation &&  exprACTC == ACTC_retainable &&
ObjCBridgeRelatedAttrFromType(castType, TDNDecl)) ||
   (exprACTC == ACTC_coreFoundation && castACTC == ACTC_retainable &&
-   ObjCBridgeRelatedAttrFromType(castExprType, TDNDecl)))
+   ObjCBridgeRelatedAttrFromType(castExprType, TDNDecl)) ||
+  (exprACTC ==ACTC_voidPtr && castACTC == ACTC_retainable &&
+   CCK == Sema::CCK_ImplicitConversion))
 return;
   
   unsigned srcKind = 0;

Modified: cfe/trunk/test/ARCMT/checking.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=211234&r1=211233&r2=211234&view=diff
==
--- cfe/trunk/test/ARCMT/checking.m (original)
+++ cfe/trunk/test/ARCMT/checking.m Wed Jun 18 17:50:40 2014
@@ -158,8 +158,8 @@ void * cvt(id arg)
   (void)(__autoreleasing id**)voidp_val;
   (void)(void*)voidp_val;
   (void)(void**)arg; // expected-error {{disallowed}}
-  cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \
-   // expected-note 2 {{use __bridge to}} expected-note {{use 
CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}}
+  cvt((void*)arg); // expected-error 1 {{requires a bridged cast}} \
+   // expected-note 1 {{use __bridge to}} expected-note {{use 
CFBridgingRetain call}}
   cvt(0);
   (void)(__strong id**)(0);
   return arg; // expected-error {{requires a bridged cast}} expected-note 
{{use __bridge}} expected-note {{use CFBridgingRetain call}}

Modified: cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result?rev=211234&r1=211233&r2=211234&view=diff
==
--- cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result (original)
+++ cfe/trunk/test/ARCMT/nonobjc-to-objc-cast.m.result Wed Jun 18 17:50:40 2014
@@ -36,7 +36,7 @@ void f(BOOL b, id p) {
   CFUUIDRef   _uuid;
   NSString *_uuidString = (NSString 
*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
   _uuidString = (NSString 
*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
-  _uuidString = CFBridgingRelease(CFRetain(_uuid));
+  _uuidString = CFRetain(_uuid);
 }
 
 @implementation NSString (StrExt)

Modified: cfe/trunk/test/SemaObjC/arc-type-conversion.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-type-conversion.m?rev=211234&r1=211233&r2=211234&view=diff
==
--- cfe/trunk/test/SemaObjC/arc-type-conversion.m (original)
+++ cfe/trunk/test/SemaObjC/arc-type-conversion.m Wed Jun 18 17:50:40 2014
@@ -16,10 +16,8 @@ void * cvt(id arg)
   (void)(void*)voidp_val;
   (void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 
'void **' is disallowed with ARC}}
   cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' 
to C pointer type 'void *' requires a bridged cast}} \
-   // expected-error {{implicit conversion of C pointer type 
'void *' to Objective-C pointer type 'id' requires a bridged cast}} \
-   // expected-note 2 {{use __bridge to convert directly (no 
change in ownership)}} \
+   // expected-note 1 {{use __bridge to convert directly (no 
change in ownership)}} \
// expected-note {{use CFBridgingRetain call to make an ARC 
object available as a +1 'void *'}} \
-   // expected-note {{use CFBridgingRelease call to transfer 
ownership of a +1 'void *' into ARC}}
   cvt(0);
   (void)(__strong id**)(0);
   return arg; // expected-error {{implicit conversion of Objective-C pointer 
type 'id' to C pointer type 'void *' requires a bridged cast}} \

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=211234&r1=211233&r2=211234&view=diff
==

Re: [PATCH] Documentation for loop unrolling pragmas.

2014-06-18 Thread Tyler Nowicki
Hi Mark,

How about

''Unrolling a loop reduces the loop control overhead and exposes more 
opportunities for ILP. Loops with a constant trip count are completely 
unrolled, eliminating all loop control overhead. Each iteration of the loop is 
enumerated in sequence in the generated code. Loops with variable trip counts 
are partially unrolled. The number of loop iterations that are partially 
unrolled is automatically determined and depends on the maximum generated code 
size of a loop.’'

Is there a setting for the maximum code size of a loop? The text would read 
better if we just referred to the setting here.

Tyler

On Jun 18, 2014, at 2:32 PM, Eli Bendersky  wrote:

> 
> Comment at: docs/LanguageExtensions.rst:1791
> @@ +1790,3 @@
> +Loop unrolling replicates the body of a loop increasing the loop size
> +and reducing the loop count.  Loop control overhead can be reduced or
> +eliminated, and additional ILP can be exposed.  The unroller selects
> 
> Maybe s/loop count/loop trip count/ for clarify? There's another instance 
> later on
> 
> 
> Comment at: docs/LanguageExtensions.rst:1793
> @@ +1792,3 @@
> +eliminated, and additional ILP can be exposed.  The unroller selects
> +an unroll count based on a limit on the growth of code size and
> +whether the loop can be unrolled completely.
> 
> I find this sentence a bit confusing in the context of unroll pragmas which 
> tell the unroller exactly how much we want to unroll. OTOH this sentence 
> seems to be describing the unrolling heuristic?
> 
> http://reviews.llvm.org/D4198
> 
> 


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r211227 - tests: relax ms-intrinsics test

2014-06-18 Thread Reid Kleckner
Oh man, the 'entry' block might be %0...  >_<

I didn't point this out in review because all the parameters retain their
names in NDEBUG builds and nothing else is named.


On Wed, Jun 18, 2014 at 2:48 PM, Saleem Abdulrasool 
wrote:

> Author: compnerd
> Date: Wed Jun 18 16:48:44 2014
> New Revision: 211227
>
> URL: http://llvm.org/viewvc/llvm-project?rev=211227&view=rev
> Log:
> tests: relax ms-intrinsics test
>
> Relax the tests to allow for differences between release and debug builds.
>  This
> should fix the buildbots.
>
> Thanks to Benjamin Kramer and Eric Christo for their invaluable tip that
> this
> was release build specific issue.
>
> Modified:
> cfe/trunk/test/CodeGen/ms-intrinsics.c
>
> Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=211227&r1=211226&r2=211227&view=diff
>
> ==
> --- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
> +++ cfe/trunk/test/CodeGen/ms-intrinsics.c Wed Jun 18 16:48:44 2014
> @@ -6,12 +6,11 @@ void *test_InterlockedExchangePointer(vo
>  }
>
>  // CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** %Target,
> i8* %Value){{.*}}{
> -// CHECK: entry:
> -// CHECK:   %0 = bitcast i8** %Target to i32*
> -// CHECK:   %1 = ptrtoint i8* %Value to i32
> -// CHECK:   %2 = atomicrmw xchg i32* %0, i32 %1 seq_cst
> -// CHECK:   %3 = inttoptr i32 %2 to i8*
> -// CHECK:   ret i8* %3
> +// CHECK:   %[[TARGET:[0-9]+]] = bitcast i8** %Target to i32*
> +// CHECK:   %[[VALUE:[0-9]+]] = ptrtoint i8* %Value to i32
> +// CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %[[TARGET]], i32
> %[[VALUE]] seq_cst
> +// CHECK:   %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXCHANGE]] to i8*
> +// CHECK:   ret i8* %[[RESULT]]
>  // CHECK: }
>
>  void *test_InterlockedCompareExchangePointer(void * volatile *Destination,
> @@ -20,14 +19,13 @@ void *test_InterlockedCompareExchangePoi
>  }
>
>  // CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8**
> %Destination, i8* %Exchange, i8* %Comparand){{.*}}{
> -// CHECK: entry:
> -// CHECK:   %0 = bitcast i8** %Destination to i32*
> -// CHECK:   %1 = ptrtoint i8* %Exchange to i32
> -// CHECK:   %2 = ptrtoint i8* %Comparand to i32
> -// CHECK:   %3 = cmpxchg volatile i32* %0, i32 %2, i32 %1 seq_cst seq_cst
> -// CHECK:   %4 = extractvalue { i32, i1 } %3, 0
> -// CHECK:   %5 = inttoptr i32 %4 to i8*
> -// CHECK:   ret i8* %5
> +// CHECK:   %[[DEST:[0-9]+]] = bitcast i8** %Destination to i32*
> +// CHECK:   %[[EXCHANGE:[0-9]+]] = ptrtoint i8* %Exchange to i32
> +// CHECK:   %[[COMPARAND:[0-9]+]] = ptrtoint i8* %Comparand to i32
> +// CHECK:   %[[XCHG:[0-9]+]] = cmpxchg volatile i32* %[[DEST:[0-9]+]],
> i32 %[[COMPARAND:[0-9]+]], i32 %[[EXCHANGE:[0-9]+]] seq_cst seq_cst
> +// CHECK:   %[[EXTRACT:[0-9]+]] = extractvalue { i32, i1 } %[[XCHG]], 0
> +// CHECK:   %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXTRACT]] to i8*
> +// CHECK:   ret i8* %[[RESULT:[0-9]+]]
>  // CHECK: }
>
>  long test_InterlockedExchange(long *Target, long Value) {
> @@ -35,7 +33,6 @@ long test_InterlockedExchange(long *Targ
>  }
>
>  // CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32
> %Value){{.*}}{
> -// CHECK: entry:
> -// CHECK:   %0 = atomicrmw xchg i32* %Target, i32 %Value seq_cst
> -// CHECK:   ret i32 %0
> +// CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %Target, i32
> %Value seq_cst
> +// CHECK:   ret i32 %[[EXCHANGE:[0-9]+]]
>  // CHECK: }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Fix PR20069: bad loop pragma arguments crash FE

2014-06-18 Thread Tyler Nowicki
Hi Mark,

Thanks for working on this! Sorry about overlooking this bug.

LGTM! I previously differentiated between keyword and value to make it obvious 
that a vector width can’t be used with vectorize() and a enable/disable can’t 
be used with vectorize_width(). But the expected string should do that still.

Tyler

On Jun 18, 2014, at 11:10 AM, Mark Heffernan  wrote:

> Hi TylerNowicki, aaron.ballman,
> 
> This patch fixes a crash when handling malformed arguments to loop pragmas 
> such as: "#pragma clang loop vectorize(()".  Essentially any argument which 
> is not an identifier or constant resulted in a crash.  This patch also 
> changes a couple of the error messages which weren't quite correct.  New 
> behavior with this patch vs old behavior:
> 
> #pragma clang loop vectorize(1)
> OLD: error: missing keyword; expected 'enable' or 'disable'
> NEW: error: invalid argument; expected 'enable' or 'disable'
> 
> #pragma clang loop vectorize()
> OLD: error: expected ')'
> NEW: error: missing argument to loop pragma 'vectorize'
> 
> #pragma clang loop vectorize_width(bad)
> OLD: error: missing value; expected a positive integer value
> NEW: error: invalid argument; expected a positive integer value
> 
> #pragma clang loop vectorize(bad)
> OLD: invalid keyword 'bad'; expected 'enable' or 'disable'
> NEW: error: invalid argument; expected 'enable' or 'disable'
> 
> In the last example above, the old behavior isn't incorrect. I made the 
> change as it simplified the code a bit and made the message consistent 
> regardless of what the argument is (rather than just printing the argument if 
> it is an identifier).  Happy to change it back if anyone thinks it's a step 
> backwards.
> 
> http://reviews.llvm.org/D4197
> 
> Files:
>  include/clang/Basic/DiagnosticParseKinds.td
>  include/clang/Basic/DiagnosticSemaKinds.td
>  lib/Parse/ParsePragma.cpp
>  lib/Sema/SemaStmtAttr.cpp
>  test/Parser/pragma-loop.cpp
> 


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Daniel Jasper
Based on the tests, I think this is (or at least might be) the wrong fix. For 
example, there can be function literals with names in other expression 
contexts, not just in braced lists, e.g.:

  var variablename = function FunctionName(Argument List) { 
// Function Body 
  };

I'll ponder this some more and get back to you.

http://reviews.llvm.org/D4190



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211227 - tests: relax ms-intrinsics test

2014-06-18 Thread Saleem Abdulrasool
Author: compnerd
Date: Wed Jun 18 16:48:44 2014
New Revision: 211227

URL: http://llvm.org/viewvc/llvm-project?rev=211227&view=rev
Log:
tests: relax ms-intrinsics test

Relax the tests to allow for differences between release and debug builds.  This
should fix the buildbots.

Thanks to Benjamin Kramer and Eric Christo for their invaluable tip that this
was release build specific issue.

Modified:
cfe/trunk/test/CodeGen/ms-intrinsics.c

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=211227&r1=211226&r2=211227&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Wed Jun 18 16:48:44 2014
@@ -6,12 +6,11 @@ void *test_InterlockedExchangePointer(vo
 }
 
 // CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** %Target, i8* 
%Value){{.*}}{
-// CHECK: entry:
-// CHECK:   %0 = bitcast i8** %Target to i32*
-// CHECK:   %1 = ptrtoint i8* %Value to i32
-// CHECK:   %2 = atomicrmw xchg i32* %0, i32 %1 seq_cst
-// CHECK:   %3 = inttoptr i32 %2 to i8*
-// CHECK:   ret i8* %3
+// CHECK:   %[[TARGET:[0-9]+]] = bitcast i8** %Target to i32*
+// CHECK:   %[[VALUE:[0-9]+]] = ptrtoint i8* %Value to i32
+// CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %[[TARGET]], i32 
%[[VALUE]] seq_cst
+// CHECK:   %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXCHANGE]] to i8*
+// CHECK:   ret i8* %[[RESULT]]
 // CHECK: }
 
 void *test_InterlockedCompareExchangePointer(void * volatile *Destination,
@@ -20,14 +19,13 @@ void *test_InterlockedCompareExchangePoi
 }
 
 // CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** 
%Destination, i8* %Exchange, i8* %Comparand){{.*}}{
-// CHECK: entry:
-// CHECK:   %0 = bitcast i8** %Destination to i32*
-// CHECK:   %1 = ptrtoint i8* %Exchange to i32
-// CHECK:   %2 = ptrtoint i8* %Comparand to i32
-// CHECK:   %3 = cmpxchg volatile i32* %0, i32 %2, i32 %1 seq_cst seq_cst
-// CHECK:   %4 = extractvalue { i32, i1 } %3, 0
-// CHECK:   %5 = inttoptr i32 %4 to i8*
-// CHECK:   ret i8* %5
+// CHECK:   %[[DEST:[0-9]+]] = bitcast i8** %Destination to i32*
+// CHECK:   %[[EXCHANGE:[0-9]+]] = ptrtoint i8* %Exchange to i32
+// CHECK:   %[[COMPARAND:[0-9]+]] = ptrtoint i8* %Comparand to i32
+// CHECK:   %[[XCHG:[0-9]+]] = cmpxchg volatile i32* %[[DEST:[0-9]+]], i32 
%[[COMPARAND:[0-9]+]], i32 %[[EXCHANGE:[0-9]+]] seq_cst seq_cst
+// CHECK:   %[[EXTRACT:[0-9]+]] = extractvalue { i32, i1 } %[[XCHG]], 0
+// CHECK:   %[[RESULT:[0-9]+]] = inttoptr i32 %[[EXTRACT]] to i8*
+// CHECK:   ret i8* %[[RESULT:[0-9]+]]
 // CHECK: }
 
 long test_InterlockedExchange(long *Target, long Value) {
@@ -35,7 +33,6 @@ long test_InterlockedExchange(long *Targ
 }
 
 // CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32 
%Value){{.*}}{
-// CHECK: entry:
-// CHECK:   %0 = atomicrmw xchg i32* %Target, i32 %Value seq_cst
-// CHECK:   ret i32 %0
+// CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %Target, i32 %Value 
seq_cst
+// CHECK:   ret i32 %[[EXCHANGE:[0-9]+]]
 // CHECK: }


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211224 - Relax the cl-inputs.c test a little bit in case link.exe is on PATH

2014-06-18 Thread Reid Kleckner
Author: rnk
Date: Wed Jun 18 16:34:36 2014
New Revision: 211224

URL: http://llvm.org/viewvc/llvm-project?rev=211224&view=rev
Log:
Relax the cl-inputs.c test a little bit in case link.exe is on PATH

Modified:
cfe/trunk/test/Driver/cl-inputs.c

Modified: cfe/trunk/test/Driver/cl-inputs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-inputs.c?rev=211224&r1=211223&r2=211224&view=diff
==
--- cfe/trunk/test/Driver/cl-inputs.c (original)
+++ cfe/trunk/test/Driver/cl-inputs.c Wed Jun 18 16:34:36 2014
@@ -41,12 +41,12 @@
 // STDINTc: "-x" "c"
 
 // RUN: env LIB=%S/Inputs/cl-libs %clang_cl -### -- %s cl-test.lib 2>&1 | 
FileCheck -check-prefix=LIBINPUT %s
-// LIBINPUT: "link.exe"
+// LIBINPUT: link.exe"
 // LIBINPUT: "cl-test.lib"
 
 // RUN: env LIB=%S/Inputs/cl-libs %clang_cl -### -- %s cl-test2.lib 2>&1 | 
FileCheck -check-prefix=LIBINPUT2 %s
 // LIBINPUT2: error: no such file or directory: 'cl-test2.lib'
-// LIBINPUT2: "link.exe"
+// LIBINPUT2: link.exe"
 // LIBINPUT2-NOT: "cl-test2.lib"
 
 void f();


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Documentation for loop unrolling pragmas.

2014-06-18 Thread Eli Bendersky

Comment at: docs/LanguageExtensions.rst:1791
@@ +1790,3 @@
+Loop unrolling replicates the body of a loop increasing the loop size
+and reducing the loop count.  Loop control overhead can be reduced or
+eliminated, and additional ILP can be exposed.  The unroller selects

Maybe s/loop count/loop trip count/ for clarify? There's another instance later 
on


Comment at: docs/LanguageExtensions.rst:1793
@@ +1792,3 @@
+eliminated, and additional ILP can be exposed.  The unroller selects
+an unroll count based on a limit on the growth of code size and
+whether the loop can be unrolled completely.

I find this sentence a bit confusing in the context of unroll pragmas which 
tell the unroller exactly how much we want to unroll. OTOH this sentence seems 
to be describing the unrolling heuristic?

http://reviews.llvm.org/D4198



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211223 - [MS-ABI] Implement typeid

2014-06-18 Thread Warren Hunt
Author: whunt
Date: Wed Jun 18 16:15:55 2014
New Revision: 211223

URL: http://llvm.org/viewvc/llvm-project?rev=211223&view=rev
Log:
[MS-ABI] Implement typeid
This patch enables clang to generate calls to __RTtypeid when lowering 
typeid on win32 targets.  Test cases are included.


Added:
cfe/trunk/test/CodeGenCXX/microsoft-abi-typeid.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=211223&r1=211222&r2=211223&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Wed Jun 18 16:15:55 2014
@@ -1642,12 +1642,45 @@ static llvm::Value *getPolymorphicOffset
   llvm_unreachable("One of our vbases should be polymorphic.");
 }
 
-static llvm::Value *EmitTypeidFromVTable(CodeGenFunction &CGF,
- const Expr *E, 
+static llvm::Value *emitRTtypeidCall(CodeGenFunction &CGF,
+ llvm::Value *Argument) {
+  llvm::Type *ArgTypes[] = {CGF.Int8PtrTy};
+  llvm::Constant *Function = CGF.CGM.CreateRuntimeFunction(
+  llvm::FunctionType::get(CGF.Int8PtrTy, ArgTypes, false), "__RTtypeid");
+  llvm::Value *Args[] = {Argument};
+  return CGF.EmitRuntimeCall(Function, Args);
+}
+
+static llvm::Value *EmitTypeidFromVTable(CodeGenFunction &CGF, const Expr *E,
  llvm::Type *StdTypeInfoPtrTy) {
   // Get the vtable pointer.
   llvm::Value *ThisPtr = CGF.EmitLValue(E).getAddress();
 
+  if (CGF.getTarget().getCXXABI().isMicrosoft()) {
+llvm::Value *CastPtr = CGF.Builder.CreateBitCast(ThisPtr, CGF.Int8PtrTy);
+const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl();
+if (CGF.getContext().getASTRecordLayout(RD).hasExtendableVFPtr())
+  return CGF.Builder.CreateBitCast(emitRTtypeidCall(CGF, CastPtr),
+   StdTypeInfoPtrTy);
+llvm::BasicBlock *EntryBlock = CGF.Builder.GetInsertBlock();
+llvm::BasicBlock *AdjustBlock = CGF.createBasicBlock("type_id.valid");
+llvm::BasicBlock *ExitBlock = CGF.createBasicBlock("type_id.call");
+CGF.Builder.CreateCondBr(CGF.Builder.CreateIsNull(CastPtr), ExitBlock,
+ AdjustBlock);
+// Emit the call block and code for it.
+CGF.EmitBlock(AdjustBlock);
+llvm::Value *AdjustedThisPtr = CGF.Builder.CreateInBoundsGEP(
+CastPtr, getPolymorphicOffset(CGF, RD, CastPtr));
+// Emit the call block and the phi nodes for it.
+CGF.EmitBlock(ExitBlock);
+llvm::PHINode *ValuePHI = CGF.Builder.CreatePHI(CGF.Int8PtrTy, 2);
+ValuePHI->addIncoming(AdjustedThisPtr, AdjustBlock);
+ValuePHI->addIncoming(llvm::Constant::getNullValue(CGF.Int8PtrTy),
+  EntryBlock);
+return CGF.Builder.CreateBitCast(emitRTtypeidCall(CGF, ValuePHI),
+ StdTypeInfoPtrTy);
+  }
+
   // C++ [expr.typeid]p2:
   //   If the glvalue expression is obtained by applying the unary * operator 
to
   //   a pointer and the pointer is a null pointer value, the typeid expression

Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-typeid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-typeid.cpp?rev=211223&view=auto
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-typeid.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-typeid.cpp Wed Jun 18 16:15:55 2014
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -emit-llvm -O2 -optzns -o - -triple=i386-pc-win32 
2>/dev/null %s | FileCheck %s
+// REQUIRES: asserts
+
+struct type_info { const char* raw_name() const; };
+namespace std { using ::type_info; }
+
+struct V { virtual void f() {}; };
+struct A : virtual V {};
+
+A a;
+int b;
+A* fn();
+
+const std::type_info* test0_typeid() { return &typeid(int); }
+// CHECK: define %struct.type_info* @"\01?test0_typeid@@YAPBUtype_info@@XZ"() 
#0 {
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\02"* 
@"\01??_R0H@8" to %struct.type_info*)
+// CHECK-NEXT: }
+
+const std::type_info* test1_typeid() { return &typeid(A); }
+// CHECK: define %struct.type_info* @"\01?test1_typeid@@YAPBUtype_info@@XZ"() 
#0 {
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\07"* 
@"\01??_R0?AUA@@@8" to %struct.type_info*)
+// CHECK-NEXT: }
+
+const std::type_info* test2_typeid() { return &typeid(&a); }
+// CHECK: define %struct.type_info* @"\01?test2_typeid@@YAPBUtype_info@@XZ"() 
#0 {
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\07"* 
@"\01??_R0PAUA@@@8" to %struct.type_info*)
+// CHECK-NEXT: }
+
+const std::type_info* test3_typeid() { return &typeid(*fn()); }
+// CHECK: define %struct.type_info* 

[PATCH] Documentation for loop unrolling pragmas.

2014-06-18 Thread Mark Heffernan
Hi eliben, TylerNowicki, aaron.ballman, gribozavr,

This patch extends the documentation for "#pragma clang loop" hints to include 
the unroll and unroll_count directives.

http://reviews.llvm.org/D4198

Files:
  docs/LanguageExtensions.rst
  docs/ReleaseNotes.rst
  include/clang/Basic/AttrDocs.td
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1770,8 +1770,9 @@
 
 The ``#pragma clang loop`` directive is used to specify hints for optimizing the
 subsequent for, while, do-while, or c++11 range-based for loop. The directive
-provides options for vectorization and interleaving. Loop hints can be specified
-before any loop and will be ignored if the optimization is not safe to apply.
+provides options for vectorization, interleaving, and unrolling. Loop hints can
+be specified before any loop and will be ignored if the optimization is not safe
+to apply.
 
 A vectorized loop performs multiple iterations of the original loop
 in parallel using vector instructions. The instruction set of the target
@@ -1786,9 +1787,16 @@
 a cost model that depends on the register pressure and generated code size to
 select the interleaving count.
 
-Vectorization is enabled by ``vectorize(enable)`` and interleaving is enabled
-by ``interleave(enable)``. This is useful when compiling with ``-Os`` to
-manually enable vectorization or interleaving.
+Loop unrolling replicates the body of a loop increasing the loop size
+and reducing the loop count.  Loop control overhead can be reduced or
+eliminated, and additional ILP can be exposed.  The unroller selects
+an unroll count based on a limit on the growth of code size and
+whether the loop can be unrolled completely.
+
+Vectorization is enabled by ``vectorize(enable)``, interleaving is enabled
+by ``interleave(enable)``, and unrolling is enabled by ``unrolling(enable)``.
+This is useful when compiling with ``-Os`` to manually enable vectorization or
+interleaving.
 
 .. code-block:: c++
 
@@ -1798,22 +1806,28 @@
 ...
   }
 
-The vector width is specified by ``vectorize_width(_value_)`` and the interleave
-count is specified by ``interleave_count(_value_)``, where
-_value_ is a positive integer. This is useful for specifying the optimal
-width/count of the set of target architectures supported by your application.
+If ``unroll(enable)`` is specified the unroller will attempt to unroll
+the loop completely if the trip count is known at compile time.  If
+the loop count is not known the loop will still be unrolled subject to
+a limit on growth of code size.
+
+The vector width is specified by ``vectorize_width(_value_)``, interleave count
+is specified by ``interleave_count(_value_)``, and unroll count is specified by
+``unroll_count(_value)``, where _value_ is a positive integer. This is useful
+for specifying the optimal width/count of the set of target architectures
+supported by your application.
 
 .. code-block:: c++
 
-
   #pragma clang loop vectorize_width(2)
   #pragma clang loop interleave_count(2)
+  #pragma clang loop unroll_count(4)
   for(...) {
 ...
   }
 
 Specifying a width/count of 1 disables the optimization, and is equivalent to
-``vectorize(disable)`` or ``interleave(disable)``.
+``vectorize(disable)``, ``interleave(disable)``, or ``unroll(disable)``.
 
 For convenience multiple loop hints can be specified on a single line.
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -101,9 +101,10 @@
 ---
 
 Loop optimization hints can be specified using the new `#pragma clang loop`
-directive just prior to the desired loop. The directive allows vectorization
-and interleaving to be enabled or disabled, and the vector width and interleave
-count to be manually specified. See language extensions for details.
+directive just prior to the desired loop. The directive allows vectorization,
+interleaving, and unrolling to be enabled or disabled. Vector width as well
+as interleave and unrolling count can be manually specified.  See language
+extensions for details.
 
 C Language Changes in Clang
 ---
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -1016,9 +1016,10 @@
   let Category = DocCatStmt;
   let Content = [{
 The ``#pragma clang loop'' directive allows loop optimization hints to be
-specified for the subsequent loop. The directive allows vectorization
-and interleaving to be enabled or disabled, and the vector width and interleave
-count to be manually specified. See `language extensions
+specified for the subsequent loop. The directive allows vectorization,
+interleaving, and unrolling to be enabled or disabled. Vector width as well
+as interleave and unrolling count 

[libcxx] r211217 - Creating 3.4.2-final from release_34 branch.

2014-06-18 Thread Tom Stellard
Author: tstellar
Date: Wed Jun 18 15:57:27 2014
New Revision: 211217

URL: http://llvm.org/viewvc/llvm-project?rev=211217&view=rev
Log:
Creating 3.4.2-final from release_34 branch.

Added:
libcxx/tags/RELEASE_34/dot2-final/   (props changed)
  - copied from r211216, libcxx/branches/release_34/

Propchange: libcxx/tags/RELEASE_34/dot2-final/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jun 18 15:57:27 2014
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:195136,195143,195693,196058,197061,197314,201843


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211216 - CodeGen: improve ms instrincics support

2014-06-18 Thread Saleem Abdulrasool
Author: compnerd
Date: Wed Jun 18 15:51:10 2014
New Revision: 211216

URL: http://llvm.org/viewvc/llvm-project?rev=211216&view=rev
Log:
CodeGen: improve ms instrincics support

Add support for _InterlockedCompareExchangePointer, _InterlockExchangePointer,
_InterlockExchange.  These are available as a compiler intrinsic on ARM and x86.
These are used directly by the Windows SDK headers without use of the intrin
header.

Added:
cfe/trunk/test/CodeGen/ms-intrinsics.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/Intrin.h

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=211216&r1=211215&r2=211216&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Jun 18 15:51:10 2014
@@ -683,9 +683,12 @@ LANGBUILTIN(__noop,   "v.",  "n", AL
 LANGBUILTIN(__debugbreak, "v",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__va_start,   "vc**.", "nt", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange, "LiLiD*LiLi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedCompareExchangePointer, "v*v*D*v*v*", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedIncrement, "LiLiD*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedDecrement, "LiLiD*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
 
 // C99 library functions
 // C99 stdlib.h

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=211216&r1=211215&r2=211216&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jun 18 15:51:10 2014
@@ -1516,6 +1516,35 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 E->getArg(0), true);
   case Builtin::BI__noop:
 return RValue::get(nullptr);
+  case Builtin::BI_InterlockedExchange:
+  case Builtin::BI_InterlockedExchangePointer:
+return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E);
+  case Builtin::BI_InterlockedCompareExchangePointer: {
+llvm::Type *RTy;
+llvm::IntegerType *IntType =
+  IntegerType::get(getLLVMContext(),
+   getContext().getTypeSize(E->getType()));
+llvm::Type *IntPtrType = IntType->getPointerTo();
+
+llvm::Value *Destination =
+  Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), IntPtrType);
+
+llvm::Value *Exchange = EmitScalarExpr(E->getArg(1));
+RTy = Exchange->getType();
+Exchange = Builder.CreatePtrToInt(Exchange, IntType);
+
+llvm::Value *Comparand =
+  Builder.CreatePtrToInt(EmitScalarExpr(E->getArg(2)), IntType);
+
+auto Result = Builder.CreateAtomicCmpXchg(Destination, Comparand, Exchange,
+  SequentiallyConsistent,
+  SequentiallyConsistent);
+Result->setVolatile(true);
+
+return 
RValue::get(Builder.CreateIntToPtr(Builder.CreateExtractValue(Result,
+ 0),
+  RTy));
+  }
   case Builtin::BI_InterlockedCompareExchange: {
 AtomicCmpXchgInst *CXI = Builder.CreateAtomicCmpXchg(
 EmitScalarExpr(E->getArg(0)),

Modified: cfe/trunk/lib/Headers/Intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/Intrin.h?rev=211216&r1=211215&r2=211216&view=diff
==
--- cfe/trunk/lib/Headers/Intrin.h (original)
+++ cfe/trunk/lib/Headers/Intrin.h Wed Jun 18 15:51:10 2014
@@ -223,8 +223,7 @@ static __inline__
 long __cdecl _InterlockedDecrement(long volatile *_Addend);
 static __inline__
 short _InterlockedDecrement16(short volatile *_Addend);
-static __inline__
-long __cdecl _InterlockedExchange(long volatile *_Target, long _Value);
+long _InterlockedExchange(long volatile *_Target, long _Value);
 static __inline__
 short _InterlockedExchange16(short volatile *_Target, short _Value);
 static __inline__
@@ -411,7 +410,6 @@ __int64 _InterlockedCompareExchange64_HL
  __int64);
 __int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination,
  __int64 _Exchange, __int64 
_Comparand);
-static __inline__
 void *_InterlockedCompareExchangePointer(void *volatile *_Destination,
  void *_Exchange, void *_Comparand);
 void *_InterlockedCompareExchangePointer_np(void *volatile *_Dest

r211215 - Objective-C. Check for integer overflow in Objective-C's

2014-06-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Wed Jun 18 15:49:02 2014
New Revision: 211215

URL: http://llvm.org/viewvc/llvm-project?rev=211215&view=rev
Log:
Objective-C. Check for integer overflow in Objective-C's
boxed expression. // rdar://16417427

Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=211215&r1=211214&r2=211215&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jun 18 15:49:02 2014
@@ -555,7 +555,7 @@ ExprResult Sema::BuildObjCBoxedExpr(Sour
 break;
   }
 }
-
+CheckForIntOverflow(ValueExpr);
 // FIXME:  Do I need to do anything special with BoolTy expressions?
 
 // Look for the appropriate method within NSNumber.

Modified: cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m?rev=211215&r1=211214&r2=211215&view=diff
==
--- cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m (original)
+++ cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m Wed Jun 18 15:49:02 2014
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1  -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1  -fsyntax-only -fblocks -triple x86_64-apple-darwin10 
-verify %s
 // rdar://10111397
 
 #if __LP64__
 typedef unsigned long NSUInteger;
+typedef long NSInteger;
 #else
 typedef unsigned int NSUInteger;
+typedef int NSInteger;
 #endif
 
 @interface NSObject
@@ -13,10 +15,23 @@ typedef unsigned int NSUInteger;
 
 @interface NSNumber : NSObject
 + (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
 + (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
 + (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value ;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ;
 @end
 
+// rdar://16417427
+int big = 1391126400;
+int thousand = 1000;
 int main() {
   NSNumber * N = @3.1415926535;  // expected-error {{declaration of 
'numberWithDouble:' is missing in NSNumber class}}
   NSNumber *noNumber = @__objc_yes; // expected-error {{declaration of 
'numberWithBool:' is missing in NSNumber class}}
@@ -32,6 +47,9 @@ int main() {
   int five = 5;
   @-five; // expected-error{{@- must be followed by a number to form an 
NSNumber object}}
   @+five; // expected-error{{@+ must be followed by a number to form an 
NSNumber object}}
+  NSNumber *av = @(139112640);
+  NSNumber *bv = @(1391126400 * 1000); // expected-warning {{overflow in 
expression; result is -443003904 with type 'int'}}
+  NSNumber *cv = @(big * thousand);
 }
 
 // Dictionary test


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Saleem Abdulrasool

Comment at: lib/CodeGen/CGBuiltin.cpp:1540
@@ +1539,3 @@
+
+Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+Exchange,

Reid Kleckner wrote:
> Saleem Abdulrasool wrote:
> > Reid Kleckner wrote:
> > > MSDN says the 'Dest' is volatile, so I'd call Result->setVolatile(true) 
> > > here.
> > Dest itself is volatile, the returned value is not.  We dont strip 
> > volatility off of Destination.  Oh, and I dont see a 
> > llvm::Value::setVolatile either.
> CreateAtomicCmpXchg should return an AtomicRMWInst* which can be made 
> volatile.  It's not the result that's volatile, it's the memory update.
Done (thanks for the clarification!); although needed an additional extract 
value due to a recent change to the cmpxchg change.

http://reviews.llvm.org/D4182



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Driver: generate file lists to pass through to linkers

2014-06-18 Thread Reid Kleckner
Broadly, I'd like to rework this to be more generic.  We should have some 
mechanism in Support to get the max command line length.  The driver should 
have some mechanism for estimating if the command line will overflow that.  The 
Tool should query that, and if it is likely to overflow, go back and put parts 
of the command into filelists or generic response files.  If you really need to 
support a linker that only supports file lists, then we'll have to change the 
representation of the command line to be a list of strings that know if they 
are inputs or flags.  That seems OK.


Comment at: lib/Driver/Tools.cpp:180
@@ +179,3 @@
+  const char *CurrentFileListName;
+  std::ofstream CurrentFileList;
+  unsigned FileListSequence = 0;

Use llvm::raw_fd_ostream.  It has less moving parts.


Comment at: lib/Driver/Tools.cpp:213
@@ +212,3 @@
+}
+CurrentFileList << II.getFilename() << std::endl;
+  } else {

This won't be correct for many linkers if the filename contains whitespace.  I 
think we need to know what kind of linker we're calling out to in order to get 
this right.  It's easy for link.exe and gnu ld, since we know exactly how they 
quote and unquote arguments.  See the response file parsing code in 
llvm/lib/Support/CommandLine.cpp.

http://reviews.llvm.org/D4104



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Reid Kleckner

Comment at: include/clang/Basic/Builtins.def:690
@@ -688,1 +689,3 @@
 LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)

Saleem Abdulrasool wrote:
> Reid Kleckner wrote:
> > MSVC doesn't provide this in 32-bit mode, but I think we can go ahead and 
> > do that anyway.
> Id be willing to do a follow up change to disable this at the sema level in 
> 32-bit x86 only if you like.  This is available in 32-bit ARM.
No need.  I always thought it was silly that they didn't go back and add this 
intrinsic for x86.


Comment at: lib/CodeGen/CGBuiltin.cpp:1540
@@ +1539,3 @@
+
+Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+Exchange,

Saleem Abdulrasool wrote:
> Reid Kleckner wrote:
> > MSDN says the 'Dest' is volatile, so I'd call Result->setVolatile(true) 
> > here.
> Dest itself is volatile, the returned value is not.  We dont strip volatility 
> off of Destination.  Oh, and I dont see a llvm::Value::setVolatile either.
CreateAtomicCmpXchg should return an AtomicRMWInst* which can be made volatile. 
 It's not the result that's volatile, it's the memory update.

http://reviews.llvm.org/D4182



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Driver: generate file lists to pass through to linkers

2014-06-18 Thread Eric Christopher
On Wed, Jun 18, 2014 at 12:52 PM, Nick Kledzik  wrote:
> On Jun 18, 2014, at 11:45 AM, Reid Kleckner  wrote:
>
> On Wed, Jun 18, 2014 at 11:12 AM, Hans Wennborg  wrote:
>>
>> Are there really linkers that we care about that don't understand
>> response files, but accept these "file list files"?
>
>
> Unfortunately, yes, ld64.  Search the source for -filelist:
> http://www.opensource.apple.com/source/ld64/ld64-123.2.1/src/ld/Options.cpp
>
>
> For background: The darwin linker (ld64) has never supported @file
> arguments, because the linker is almost always invoked through the clang (or
> gcc before that) driver which expanded @file and passed its content as
> arguments to the linker.   Therefore @file never made it to the linker.  The
> darwin linker option for a file containing a list of files is -filelist
> .
>
> Is the motivation for this is that some OSs have a limit to the number/size
> of command line arguments?  Or that clang internally has limits?
>

I think it's the former fwiw. Some link lines can get quite long.

-eric
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Saleem Abdulrasool

Comment at: include/clang/Basic/Builtins.def:690
@@ -688,1 +689,3 @@
 LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)

Reid Kleckner wrote:
> MSVC doesn't provide this in 32-bit mode, but I think we can go ahead and do 
> that anyway.
Id be willing to do a follow up change to disable this at the sema level in 
32-bit x86 only if you like.  This is available in 32-bit ARM.


Comment at: lib/CodeGen/CGBuiltin.cpp:1535
@@ +1534,3 @@
+RTy = Exchange->getType();
+Exchange = Builder.CreatePtrToInt(Exchange, CGM.Int32Ty);
+

Reid Kleckner wrote:
> CGM.Int32Ty doesn't seem correct for x64, it should be IntType.
Good catch!


Comment at: lib/CodeGen/CGBuiltin.cpp:1537
@@ +1536,3 @@
+
+llvm::Value *Comparend =
+  Builder.CreatePtrToInt(EmitScalarExpr(E->getArg(2)), CGM.Int32Ty);

Reid Kleckner wrote:
> MSDN says "Comparand" with an 'a'.
Done.


Comment at: lib/CodeGen/CGBuiltin.cpp:1540
@@ +1539,3 @@
+
+Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+Exchange,

Reid Kleckner wrote:
> MSDN says the 'Dest' is volatile, so I'd call Result->setVolatile(true) here.
Dest itself is volatile, the returned value is not.  We dont strip volatility 
off of Destination.  Oh, and I dont see a llvm::Value::setVolatile either.

http://reviews.llvm.org/D4182



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Driver: generate file lists to pass through to linkers

2014-06-18 Thread Nick Kledzik
On Jun 18, 2014, at 11:45 AM, Reid Kleckner  wrote:
> On Wed, Jun 18, 2014 at 11:12 AM, Hans Wennborg  wrote:
> Are there really linkers that we care about that don't understand
> response files, but accept these "file list files"?
> 
> Unfortunately, yes, ld64.  Search the source for -filelist: 
> http://www.opensource.apple.com/source/ld64/ld64-123.2.1/src/ld/Options.cpp

For background: The darwin linker (ld64) has never supported @file arguments, 
because the linker is almost always invoked through the clang (or gcc before 
that) driver which expanded @file and passed its content as arguments to the 
linker.   Therefore @file never made it to the linker.  The darwin linker 
option for a file containing a list of files is -filelist .

Is the motivation for this is that some OSs have a limit to the number/size of 
command line arguments?  Or that clang internally has limits?  

-Nick

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[libclc] r211211 - Add pown

2014-06-18 Thread Jeroen Ketema
Author: jketema
Date: Wed Jun 18 14:42:23 2014
New Revision: 211211

URL: http://llvm.org/viewvc/llvm-project?rev=211211&view=rev
Log:
Add pown

Reviewed-by: Tom Stellard 

Added:
libclc/trunk/generic/include/clc/math/pown.h
libclc/trunk/generic/lib/math/pown.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=211211&r1=211210&r2=211211&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Jun 18 14:42:23 2014
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/pown.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/pown.h?rev=211211&view=auto
==
--- libclc/trunk/generic/include/clc/math/pown.h (added)
+++ libclc/trunk/generic/include/clc/math/pown.h Wed Jun 18 14:42:23 2014
@@ -0,0 +1,24 @@
+#define _CLC_POWN_INTRINSIC "llvm.powi"
+
+#define _CLC_POWN_DECL(GENTYPE, INTTYPE) \
+  _CLC_OVERLOAD _CLC_DECL GENTYPE pown(GENTYPE x, INTTYPE y);
+
+#define _CLC_VECTOR_POWN_DECL(GENTYPE, INTTYPE) \
+  _CLC_POWN_DECL(GENTYPE##2, INTTYPE##2)  \
+  _CLC_POWN_DECL(GENTYPE##3, INTTYPE##3)  \
+  _CLC_POWN_DECL(GENTYPE##4, INTTYPE##4)  \
+  _CLC_POWN_DECL(GENTYPE##8, INTTYPE##8)  \
+  _CLC_POWN_DECL(GENTYPE##16, INTTYPE##16)
+
+_CLC_OVERLOAD float pown(float x, int y) __asm(_CLC_POWN_INTRINSIC ".f32");
+
+_CLC_VECTOR_POWN_DECL(float, int)
+
+#ifdef cl_khr_fp64
+_CLC_OVERLOAD double pown(double x, int y) __asm(_CLC_POWN_INTRINSIC ".f64");
+_CLC_VECTOR_POWN_DECL(double, int)
+#endif
+
+#undef _CLC_POWN_INTRINSIC
+#undef _CLC_POWN_DECL
+#undef _CLC_VECTOR_POWN_DECL

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=211211&r1=211210&r2=211211&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Jun 18 14:42:23 2014
@@ -35,6 +35,7 @@ math/mad.cl
 math/mix.cl
 math/clc_nextafter.cl
 math/nextafter.cl
+math/pown.cl
 math/sincos.cl
 relational/all.cl
 relational/any.cl

Added: libclc/trunk/generic/lib/math/pown.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/pown.cl?rev=211211&view=auto
==
--- libclc/trunk/generic/lib/math/pown.cl (added)
+++ libclc/trunk/generic/lib/math/pown.cl Wed Jun 18 14:42:23 2014
@@ -0,0 +1,9 @@
+#include 
+
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, pown, float, int)
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, pown, double, int)
+#endif


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[libclc] r211210 - Add missing undefs

2014-06-18 Thread Jeroen Ketema
Author: jketema
Date: Wed Jun 18 14:37:34 2014
New Revision: 211210

URL: http://llvm.org/viewvc/llvm-project?rev=211210&view=rev
Log:
Add missing undefs

Reviewed-by: Tom Stellard 

Modified:
libclc/trunk/generic/include/clc/relational/all.h
libclc/trunk/generic/include/clc/relational/isequal.h

Modified: libclc/trunk/generic/include/clc/relational/all.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/all.h?rev=211210&r1=211209&r2=211210&view=diff
==
--- libclc/trunk/generic/include/clc/relational/all.h (original)
+++ libclc/trunk/generic/include/clc/relational/all.h Wed Jun 18 14:37:34 2014
@@ -1,4 +1,3 @@
-
 #define _CLC_ALL_DECL(TYPE) \
   _CLC_OVERLOAD _CLC_DECL int all(TYPE v);
 
@@ -14,3 +13,6 @@ _CLC_VECTOR_ALL_DECL(char)
 _CLC_VECTOR_ALL_DECL(short)
 _CLC_VECTOR_ALL_DECL(int)
 _CLC_VECTOR_ALL_DECL(long)
+
+#undef _CLC_ALL_DECL
+#undef _CLC_VECTOR_ALL_DECL

Modified: libclc/trunk/generic/include/clc/relational/isequal.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/isequal.h?rev=211210&r1=211209&r2=211210&view=diff
==
--- libclc/trunk/generic/include/clc/relational/isequal.h (original)
+++ libclc/trunk/generic/include/clc/relational/isequal.h Wed Jun 18 14:37:34 
2014
@@ -1,4 +1,3 @@
-
 #define _CLC_ISEQUAL_DECL(TYPE, RETTYPE) \
   _CLC_OVERLOAD _CLC_DECL RETTYPE isequal(TYPE x, TYPE y);
 
@@ -15,4 +14,7 @@ _CLC_VECTOR_ISEQUAL_DECL(float, int)
 #ifdef cl_khr_fp64
 _CLC_ISEQUAL_DECL(double, int)
 _CLC_VECTOR_ISEQUAL_DECL(double, long)
-#endif
\ No newline at end of file
+#endif
+
+#undef _CLC_ISEQUAL_DECL
+#undef _CLC_VECTOR_ISEQUAL_DEC


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211209 - [analyzer] Don't create new PostStmt nodes if we don't have to.

2014-06-18 Thread Jordan Rose
Author: jrose
Date: Wed Jun 18 14:23:30 2014
New Revision: 211209

URL: http://llvm.org/viewvc/llvm-project?rev=211209&view=rev
Log:
[analyzer] Don't create new PostStmt nodes if we don't have to.

Doing this caused us to mistakenly think we'd seen a particular state before
when we actually hadn't, which resulted in false negatives. Credit to
Rafael Auler for discovering this issue!

Added:
cfe/trunk/test/Analysis/retain-release-cache-out.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=211209&r1=211208&r2=211209&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Wed Jun 18 14:23:30 2014
@@ -541,7 +541,7 @@ void CoreEngine::enqueueStmtNode(Explode
   CFGStmt CS = (*Block)[Idx].castAs();
   PostStmt Loc(CS.getStmt(), N->getLocationContext());
 
-  if (Loc == N->getLocation()) {
+  if (Loc == N->getLocation().withTag(nullptr)) {
 // Note: 'N' should be a fresh node because otherwise it shouldn't be
 // a member of Deferred.
 WList->enqueue(N, Block, Idx+1);

Added: cfe/trunk/test/Analysis/retain-release-cache-out.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release-cache-out.m?rev=211209&view=auto
==
--- cfe/trunk/test/Analysis/retain-release-cache-out.m (added)
+++ cfe/trunk/test/Analysis/retain-release-cache-out.m Wed Jun 18 14:23:30 2014
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze %s -analyzer-checker=core,osx.cocoa.RetainCount 
-fblocks -verify
+
+// This test is checking behavior when a single checker runs only with the core
+// checkers, testing that the traversal order in the CFG does not affect the
+// reporting of an error.
+
+#import "Inputs/system-header-simulator-objc.h"
+
+void testDoubleRelease(BOOL z) {
+  id x = [[NSObject alloc] init];
+  if (z) {
+[x release];
+  } else {
+;
+  }
+  [x release]; // expected-warning {{Reference-counted object is used after it 
is released}}
+}
+
+void testDoubleRelease2(BOOL z) {
+  id x = [[NSObject alloc] init];
+  if (z) {
+;
+  } else {
+[x release];
+  }
+  [x release]; // expected-warning {{Reference-counted object is used after it 
is released}}
+}


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Adam Strzelecki
Added tests.

http://reviews.llvm.org/D4190

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTestJS.cpp

Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -184,6 +184,14 @@
"return 1;\n"
"  }\n"
"};");
+  verifyFormat("function outer1(a, b) {\n"
+   "  function inner1(a, b) { return a; }\n"
+   "  inner1(a, b);\n"
+   "}\n"
+   "function outer2(a, b) {\n"
+   "  function inner2(a, b) { return a; }\n"
+   "  inner2(a, b);\n"
+   "}");
 }
 
 TEST_F(FormatTestJS, MultipleFunctionLiterals) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -184,6 +184,14 @@
"return 1;\n"
"  }\n"
"};");
+  verifyFormat("function outer1(a, b) {\n"
+   "  function inner1(a, b) { return a; }\n"
+   "  inner1(a, b);\n"
+   "}\n"
+   "function outer2(a, b) {\n"
+   "  function inner2(a, b) { return a; }\n"
+   "  inner2(a, b);\n"
+   "}");
 }
 
 TEST_F(FormatTestJS, MultipleFunctionLiterals) {
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Driver: generate file lists to pass through to linkers

2014-06-18 Thread Reid Kleckner
On Wed, Jun 18, 2014 at 11:12 AM, Hans Wennborg  wrote:
>
> Are there really linkers that we care about that don't understand
> response files, but accept these "file list files"?
>

Unfortunately, yes, ld64.  Search the source for -filelist:
http://www.opensource.apple.com/source/ld64/ld64-123.2.1/src/ld/Options.cpp
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Reid Kleckner
lgtm with some nits


Comment at: include/clang/Basic/Builtins.def:690
@@ -688,1 +689,3 @@
 LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)

MSVC doesn't provide this in 32-bit mode, but I think we can go ahead and do 
that anyway.


Comment at: lib/CodeGen/CGBuiltin.cpp:1523
@@ +1522,3 @@
+  }
+  case Builtin::BI_InterlockedCompareExchangePointer: {
+llvm::Type *RTy;

I'd like this to be factored better, but I can live with it as is.


Comment at: lib/CodeGen/CGBuiltin.cpp:1535
@@ +1534,3 @@
+RTy = Exchange->getType();
+Exchange = Builder.CreatePtrToInt(Exchange, CGM.Int32Ty);
+

CGM.Int32Ty doesn't seem correct for x64, it should be IntType.


Comment at: lib/CodeGen/CGBuiltin.cpp:1537
@@ +1536,3 @@
+
+llvm::Value *Comparend =
+  Builder.CreatePtrToInt(EmitScalarExpr(E->getArg(2)), CGM.Int32Ty);

MSDN says "Comparand" with an 'a'.


Comment at: lib/CodeGen/CGBuiltin.cpp:1540
@@ +1539,3 @@
+
+Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+Exchange,

MSDN says the 'Dest' is volatile, so I'd call Result->setVolatile(true) here.

http://reviews.llvm.org/D4182



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Warren Hunt
lgtm

http://reviews.llvm.org/D4182



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211197 - Objective-C. Try to fix the test in buildbot in my last patch.

2014-06-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Wed Jun 18 13:16:37 2014
New Revision: 211197

URL: http://llvm.org/viewvc/llvm-project?rev=211197&view=rev
Log:
Objective-C. Try to fix the test in buildbot in my last patch.

Modified:
cfe/trunk/test/SemaObjC/class-unavail-warning.m

Modified: cfe/trunk/test/SemaObjC/class-unavail-warning.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-unavail-warning.m?rev=211197&r1=211196&r2=211197&view=diff
==
--- cfe/trunk/test/SemaObjC/class-unavail-warning.m (original)
+++ cfe/trunk/test/SemaObjC/class-unavail-warning.m Wed Jun 18 13:16:37 2014
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only  -triple x86_64-apple-darwin10 -verify %s
 // rdar://9092208
 
 __attribute__((unavailable("not available")))


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [libcxx] Partially address a FIXME in steady_clock::now()

2014-06-18 Thread Aaron Ballman
On Fri, Jun 6, 2014 at 1:08 PM, Jon Roelofs  wrote:
> Hi mclow.lists,
>
> http://reviews.llvm.org/D4045
>
> Files:
>   libcxx/src/chrono.cpp
>
> Index: libcxx/src/chrono.cpp
> ===
> --- libcxx/src/chrono.cpp
> +++ libcxx/src/chrono.cpp
> @@ -108,11 +108,6 @@
>  }
>
>  #else  // __APPLE__
> -// FIXME: We assume that clock_gettime(CLOCK_MONOTONIC) works on
> -// non-apple systems.  Instead, we should check _POSIX_TIMERS and
> -// _POSIX_MONOTONIC_CLOCK and fall back to something else if those
> -// don't exist.
> -
>  // Warning:  If this is not truly steady, then it is non-conforming.  It is
>  //  better for it to not exist and have the rest of libc++ use system_clock
>  //  instead.
> @@ -120,10 +115,18 @@
>  steady_clock::time_point
>  steady_clock::now() _NOEXCEPT
>  {
> +#if (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) && \
> +(defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0)
>  struct timespec tp;
>  if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
>  __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
>  return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
> +#else
> +#warning According to unistd.h, there is no monotonic clock on this system 
> so \
> + we're falling back to std::system_clock (which may not be \
> + monotonic, and therefore may not be conforming).

This is presuming that the compiler being used to compile libc++
understands what #warning is, which ties us to compiler
implementations. So, for instance, this code will fail to compile
entirely with MSVC.

> +return time_point(system_clock::now().time_since_epoch());
> +#endif
>  }
>  #endif  // __APPLE__

~Aaron
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Driver: generate file lists to pass through to linkers

2014-06-18 Thread Hans Wennborg
On Tue, Jun 17, 2014 at 11:27 AM, Saleem Abdulrasool  wrote:
> ping
>
> http://reviews.llvm.org/D4104

I'm still not a fan of the complexity this adds to AddLinkerInputs:
careful logic to open and close numbered rsp files, etc., whereas the
usual work of this function is just to add some inputs to a vector.

Even if we can't push this response file stuff all the way down to
when we invoke subprocesses, I think that building the list of
arguments, and possibly putting some of them in a response file should
be separate things.

Are there really linkers that we care about that don't understand
response files, but accept these "file list files"?

 - Hans
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] Fix PR20069: bad loop pragma arguments crash FE

2014-06-18 Thread Mark Heffernan
Hi TylerNowicki, aaron.ballman,

This patch fixes a crash when handling malformed arguments to loop pragmas such 
as: "#pragma clang loop vectorize(()".  Essentially any argument which is not 
an identifier or constant resulted in a crash.  This patch also changes a 
couple of the error messages which weren't quite correct.  New behavior with 
this patch vs old behavior:

#pragma clang loop vectorize(1)
OLD: error: missing keyword; expected 'enable' or 'disable'
NEW: error: invalid argument; expected 'enable' or 'disable'

#pragma clang loop vectorize()
OLD: error: expected ')'
NEW: error: missing argument to loop pragma 'vectorize'

#pragma clang loop vectorize_width(bad)
OLD: error: missing value; expected a positive integer value
NEW: error: invalid argument; expected a positive integer value

#pragma clang loop vectorize(bad)
OLD: invalid keyword 'bad'; expected 'enable' or 'disable'
NEW: error: invalid argument; expected 'enable' or 'disable'

In the last example above, the old behavior isn't incorrect. I made the change 
as it simplified the code a bit and made the message consistent regardless of 
what the argument is (rather than just printing the argument if it is an 
identifier).  Happy to change it back if anyone thinks it's a step backwards.

http://reviews.llvm.org/D4197

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/Parser/pragma-loop.cpp
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -904,6 +904,8 @@
 def err_pragma_loop_invalid_option : Error<
   "%select{invalid|missing}0 option%select{ %1|}0; expected vectorize, "
   "vectorize_width, interleave, interleave_count, unroll, or unroll_count">;
+def err_pragma_loop_missing_argument : Error<
+  "missing argument to loop pragma %0">;
 } // end of Parse Issue category.
 
 let CategoryName = "Modules Issue" in {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -543,9 +543,9 @@
 def note_surrounding_namespace_starts_here : Note<
   "surrounding namespace with visibility attribute starts here">;
 def err_pragma_loop_invalid_value : Error<
-  "%select{invalid|missing}0 value%select{ %1|}0; expected a positive integer value">;
+  "invalid argument; expected a positive integer value">;
 def err_pragma_loop_invalid_keyword : Error<
-  "%select{invalid|missing}0 keyword%select{ %1|}0; expected 'enable' or 'disable'">;
+  "invalid argument; expected 'enable' or 'disable'">;
 def err_pragma_loop_compatibility : Error<
   "%select{incompatible|duplicate}0 directives '%1(%2)' and '%3(%4)'">;
 def err_pragma_loop_precedes_nonloop : Error<
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -1710,9 +1710,13 @@
 // FIXME: All tokens between '(' and ')' should be stored and parsed as a
 // constant expression.
 PP.Lex(Tok);
-Token Value;
-if (Tok.is(tok::identifier) || Tok.is(tok::numeric_constant))
-  Value = Tok;
+if (Tok.is(tok::r_paren)) {
+  // Nothing between the parentheses.
+  PP.Diag(Tok.getLocation(), diag::err_pragma_loop_missing_argument)
+  << OptionInfo;
+  return;
+}
+Token Value = Tok;
 
 // Read ')'
 PP.Lex(Tok);
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -75,35 +75,26 @@
   if (Option == LoopHintAttr::Vectorize || Option == LoopHintAttr::Interleave ||
   Option == LoopHintAttr::Unroll) {
 if (!ValueInfo) {
-  S.Diag(ValueLoc->Loc, diag::err_pragma_loop_invalid_keyword)
-  << /*MissingKeyword=*/true << "";
+  S.Diag(ValueLoc->Loc, diag::err_pragma_loop_invalid_keyword);
   return nullptr;
 }
-
 if (ValueInfo->isStr("disable"))
   ValueInt = 0;
 else if (ValueInfo->isStr("enable"))
   ValueInt = 1;
 else {
-  S.Diag(ValueLoc->Loc, diag::err_pragma_loop_invalid_keyword)
-  << /*MissingKeyword=*/false << ValueInfo;
+  S.Diag(ValueLoc->Loc, diag::err_pragma_loop_invalid_keyword);
   return nullptr;
 }
   } else if (Option == LoopHintAttr::VectorizeWidth ||
  Option == LoopHintAttr::InterleaveCount ||
  Option == LoopHintAttr::UnrollCount) {
 // FIXME: We should support template parameters for the loop hint value.
 // See bug report #19610.
 llvm::APSInt ValueAPS;
-if (!ValueExpr || !ValueExpr->isIntegerConstantExpr(ValueAPS, S.Context)) {
-  S.Diag(ValueLoc->Loc, diag::err_pragma_loop_invalid_val

r211195 - Objective-C. Attributes on class declarations carry over

2014-06-18 Thread Fariborz Jahanian
Author: fjahanian
Date: Wed Jun 18 12:58:27 2014
New Revision: 211195

URL: http://llvm.org/viewvc/llvm-project?rev=211195&view=rev
Log:
Objective-C. Attributes on class declarations carry over
to forward class declarations for diagnosis. 
// rdar://16681279

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/class-unavail-warning.m

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=211195&r1=211194&r2=211195&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jun 18 12:58:27 2014
@@ -87,6 +87,12 @@ static AvailabilityResult DiagnoseAvaila
   bool ObjCPropertyAccess) {
   // See if this declaration is unavailable or deprecated.
   std::string Message;
+
+  // Forward class declarations get their attributes from their definition.
+  if (ObjCInterfaceDecl *IDecl = dyn_cast(D)) {
+if (IDecl->getDefinition())
+  D = IDecl->getDefinition();
+  }
   AvailabilityResult Result = D->getAvailability(&Message);
   if (const EnumConstantDecl *ECD = dyn_cast(D))
 if (Result == AR_Available) {

Modified: cfe/trunk/test/SemaObjC/class-unavail-warning.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-unavail-warning.m?rev=211195&r1=211194&r2=211195&view=diff
==
--- cfe/trunk/test/SemaObjC/class-unavail-warning.m (original)
+++ cfe/trunk/test/SemaObjC/class-unavail-warning.m Wed Jun 18 12:58:27 2014
@@ -15,7 +15,7 @@ __attribute__((unavailable("not availabl
 
 @end
 
-@interface Foo {
+@interface Gorf {
   MyClass *ivar; // expected-error {{unavailable}}
 }
 - (MyClass *)meth; // expected-error {{unavailable}}
@@ -40,3 +40,30 @@ int main() {
 
  return 0;
 }
+
+// rdar://16681279
+@interface NSObject @end
+
+__attribute__((visibility("default"))) 
__attribute__((availability(macosx,unavailable)))
+@interface Foo : NSObject @end // expected-note 3 {{'Foo' has been explicitly 
marked unavailable here}}
+@interface AppDelegate  : NSObject
+@end
+
+@class Foo;
+
+@implementation AppDelegate
+- (void) applicationDidFinishLaunching
+{
+  Foo *foo = 0; // expected-error {{'Foo' is unavailable}}
+}
+@end
+
+@class Foo;
+Foo *g_foo = 0; // expected-error {{'Foo' is unavailable}}
+
+@class Foo;
+@class Foo;
+@class Foo;
+Foo * f_func() { // expected-error {{'Foo' is unavailable}}
+  return 0; 
+}


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Saleem Abdulrasool
Fix Intrin.h with minor oversights caught by Warren.

http://reviews.llvm.org/D4182

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/Intrin.h
  test/CodeGen/ms-intrinsics.c
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -683,9 +683,12 @@
 LANGBUILTIN(__debugbreak, "v",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__va_start,   "vc**.", "nt", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange, "LiLiD*LiLi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedCompareExchangePointer, "v*v*D*v*v*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedIncrement, "LiLiD*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedDecrement, "LiLiD*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
 
 // C99 library functions
 // C99 stdlib.h
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1516,6 +1516,34 @@
 E->getArg(0), true);
   case Builtin::BI__noop:
 return RValue::get(nullptr);
+  case Builtin::BI_InterlockedExchange:
+  case Builtin::BI_InterlockedExchangePointer: {
+return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E);
+  }
+  case Builtin::BI_InterlockedCompareExchangePointer: {
+llvm::Type *RTy;
+llvm::IntegerType *IntType =
+  IntegerType::get(getLLVMContext(),
+   getContext().getTypeSize(E->getType()));
+llvm::Type *IntPtrType = IntType->getPointerTo();
+
+llvm::Value *Destination =
+  Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), IntPtrType);
+
+llvm::Value *Exchange = EmitScalarExpr(E->getArg(1));
+RTy = Exchange->getType();
+Exchange = Builder.CreatePtrToInt(Exchange, CGM.Int32Ty);
+
+llvm::Value *Comparend =
+  Builder.CreatePtrToInt(EmitScalarExpr(E->getArg(2)), CGM.Int32Ty);
+
+Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+Exchange,
+SequentiallyConsistent,
+SequentiallyConsistent);
+Result = Builder.CreateIntToPtr(Result, RTy);
+return RValue::get(Result);
+  }
   case Builtin::BI_InterlockedCompareExchange: {
 AtomicCmpXchgInst *CXI = Builder.CreateAtomicCmpXchg(
 EmitScalarExpr(E->getArg(0)),
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -223,8 +223,7 @@
 long __cdecl _InterlockedDecrement(long volatile *_Addend);
 static __inline__
 short _InterlockedDecrement16(short volatile *_Addend);
-static __inline__
-long __cdecl _InterlockedExchange(long volatile *_Target, long _Value);
+long _InterlockedExchange(long volatile *_Target, long _Value);
 static __inline__
 short _InterlockedExchange16(short volatile *_Target, short _Value);
 static __inline__
@@ -411,7 +410,6 @@
  __int64);
 __int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination,
  __int64 _Exchange, __int64 _Comparand);
-static __inline__
 void *_InterlockedCompareExchangePointer(void *volatile *_Destination,
  void *_Exchange, void *_Comparand);
 void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination,
@@ -422,7 +420,6 @@
 __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);
 static __inline__
 __int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value);
-static __inline__
 void *_InterlockedExchangePointer(void *volatile *_Target, void *_Value);
 static __inline__
 __int64 _InterlockedIncrement64(__int64 volatile *_Addend);
@@ -785,22 +782,12 @@
   __atomic_exchange(_Target, &_Value, &_Value, 0);
   return _Value;
 }
-static __inline__ long __attribute__((__always_inline__, __nodebug__))
-_InterlockedExchange(long volatile *_Target, long _Value) {
-  __atomic_exchange(_Target, &_Value, &_Value, 0);
-  return _Value;
-}
 #ifdef __x86_64__
 static __inline__ __int64 __attribute__((__always_inline__, __nodebug__))
 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value) {
   __atomic_exchange(_Target, &_Value, &_Value, 0);
   return _Value;
 }
-static __inline__ void *__attribute__((__always_inline__, __nodebug__))
-_InterlockedExchangePointer(void *volatile *_Target, void *_Value) {
-  __atomic_exchange(_Target, &_Value, &_Value, 0);
-  return _Value;
-}
 #endif
 /**\
 |* Interlocked 

[libcxx] r211191 - Formatting improvements in the synopsis suggested by RSmith. No functionality change.

2014-06-18 Thread Marshall Clow
Author: marshall
Date: Wed Jun 18 12:44:04 2014
New Revision: 211191

URL: http://llvm.org/viewvc/llvm-project?rev=211191&view=rev
Log:
Formatting improvements in the  synopsis suggested by RSmith. No 
functionality change.

Modified:
libcxx/trunk/include/experimental/string_view

Modified: libcxx/trunk/include/experimental/string_view
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=211191&r1=211190&r2=211191&view=diff
==
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Wed Jun 18 12:44:04 2014
@@ -55,6 +55,110 @@ namespace std {
 typedef basic_string_view u32string_view;
 typedef basic_string_view wstring_view;
 
+template>
+class basic_string_view {
+  public:
+  // types
+  typedef traits traits_type;
+  typedef charT value_type;
+  typedef charT* pointer;
+  typedef const charT* const_pointer;
+  typedef charT& reference;
+  typedef const charT& const_reference;
+  typedef implementation-defined const_iterator;
+  typedef const_iterator iterator;
+  typedef reverse_iterator const_reverse_iterator;
+  typedef const_reverse_iterator reverse_iterator;
+  typedef size_t size_type;
+  typedef ptrdiff_t difference_type;
+  static constexpr size_type npos = size_type(-1);
+
+  // 7.3, basic_string_view constructors and assignment operators
+  constexpr basic_string_view() noexcept;
+  constexpr basic_string_view(const basic_string_view&) noexcept = default;
+  basic_string_view& operator=(const basic_string_view&) noexcept = 
default;
+  template
+  basic_string_view(const basic_string& str) 
noexcept;
+  constexpr basic_string_view(const charT* str);
+  constexpr basic_string_view(const charT* str, size_type len);
+
+  // 7.4, basic_string_view iterator support
+  constexpr const_iterator begin() const noexcept;
+  constexpr const_iterator end() const noexcept;
+  constexpr const_iterator cbegin() const noexcept;
+  constexpr const_iterator cend() const noexcept;
+  const_reverse_iterator rbegin() const noexcept;
+  const_reverse_iterator rend() const noexcept;
+  const_reverse_iterator crbegin() const noexcept;
+  const_reverse_iterator crend() const noexcept;
+
+  // 7.5, basic_string_view capacity
+  constexpr size_type size() const noexcept;
+  constexpr size_type length() const noexcept;
+  constexpr size_type max_size() const noexcept;
+  constexpr bool empty() const noexcept;
+
+  // 7.6, basic_string_view element access
+  constexpr const_reference operator[](size_type pos) const;
+  constexpr const_reference at(size_type pos) const;
+  constexpr const_reference front() const;
+  constexpr const_reference back() const;
+  constexpr const_pointer data() const noexcept;
+
+  // 7.7, basic_string_view modifiers
+  constexpr void clear() noexcept;
+  constexpr void remove_prefix(size_type n);
+  constexpr void remove_suffix(size_type n);
+  constexpr void swap(basic_string_view& s) noexcept;
+
+  // 7.8, basic_string_view string operations
+  template
+  explicit operator basic_string() const;
+  template>
+  basic_string to_string(
+const Allocator& a = Allocator()) const;
+
+  size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+  constexpr basic_string_view substr(size_type pos = 0, size_type n = 
npos) const;
+  constexpr int compare(basic_string_view s) const noexcept;
+  constexpr int compare(size_type pos1, size_type n1, basic_string_view s) 
const;
+  constexpr int compare(size_type pos1, size_type n1,
+basic_string_view s, size_type pos2, size_type n2) 
const;
+  constexpr int compare(const charT* s) const;
+  constexpr int compare(size_type pos1, size_type n1, const charT* s) 
const;
+  constexpr int compare(size_type pos1, size_type n1,
+const charT* s, size_type n2) const;
+  constexpr size_type find(basic_string_view s, size_type pos = 0) const 
noexcept;
+  constexpr size_type find(charT c, size_type pos = 0) const noexcept;
+  constexpr size_type find(const charT* s, size_type pos, size_type n) 
const;
+  constexpr size_type find(const charT* s, size_type pos = 0) const;
+  constexpr size_type rfind(basic_string_view s, size_type pos = npos) 
const noexcept;
+  constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
+  constexpr size_type rfind(const charT* s, size_type pos, size_type n) 
const;
+  constexpr size_type rfind(const charT* s, size_type pos = npos) const;
+  constexpr size_type find_first_of(basic_string_view s, size_type pos = 
0) const noexcept;
+  constexpr size_type find_first_of(charT c, size_type pos 

Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Saleem Abdulrasool

Comment at: lib/Headers/Intrin.h:227
@@ -226,3 +226,3 @@
 static __inline__
-long __cdecl _InterlockedExchange(long volatile *_Target, long _Value);
 static __inline__

Warren Hunt wrote:
> I don't see why it was necessary to get rid of __cdecl.  Also, Now that the 
> definition is gone it shouldn't be static __inline__ anymore.
Getting rid of `__cdecl` is actually quite important since this header is not 
x86 specific.  ARM does not honour `__cdecl`, and thus generates a warning.

Good catch about the static `__inline__`.  I've become too accustomed to the 
LLVM style and didnt notice that.

http://reviews.llvm.org/D4182



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [libcxx] Partially address a FIXME in steady_clock::now()

2014-06-18 Thread Jon Roelofs
Ping

http://reviews.llvm.org/D4045



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211189 - Make clang-cl accept .lib inputs (PR20065)

2014-06-18 Thread Hans Wennborg
Author: hans
Date: Wed Jun 18 12:21:50 2014
New Revision: 211189

URL: http://llvm.org/viewvc/llvm-project?rev=211189&view=rev
Log:
Make clang-cl accept .lib inputs (PR20065)

Patch by Ehsan Akhgari!

(Tiny tweak by me: renamed PathSegment to LibDir.)

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

Added:
cfe/trunk/test/Driver/Inputs/cl-libs/
cfe/trunk/test/Driver/Inputs/cl-libs/cl-test.lib
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-inputs.c

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=211189&r1=211188&r2=211189&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jun 18 12:21:50 2014
@@ -21,6 +21,7 @@
 #include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/Arg.h"
@@ -33,6 +34,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -927,6 +929,35 @@ void Driver::BuildUniversalActions(const
   }
 }
 
+/// \brief Check whether the file referenced by Value exists in the LIB
+/// environment variable.
+static bool ExistsInLibDir(StringRef Value) {
+  llvm::Optional OptPath = llvm::sys::Process::GetEnv("LIB");
+  if (!OptPath.hasValue())
+return false;
+
+#ifdef LLVM_ON_WIN32
+  const StringRef PathSeparators = ";";
+#else
+  const StringRef PathSeparators = ":";
+#endif
+
+  SmallVector LibDirs;
+  llvm::SplitString(OptPath.getValue(), LibDirs, PathSeparators);
+
+  for (const auto &LibDir : LibDirs) {
+if (LibDir.empty())
+  continue;
+
+SmallString<128> FilePath(LibDir);
+llvm::sys::path::append(FilePath, Value);
+if (llvm::sys::fs::exists(Twine(FilePath)))
+  return true;
+  }
+
+  return false;
+}
+
 /// \brief Check that the file referenced by Value exists. If it doesn't,
 /// issue a diagnostic and return false.
 static bool DiagnoseInputExistence(const Driver &D, const DerivedArgList &Args,
@@ -950,6 +981,9 @@ static bool DiagnoseInputExistence(const
   if (llvm::sys::fs::exists(Twine(Path)))
 return true;
 
+  if (D.IsCLMode() && ExistsInLibDir(Value))
+return true;
+
   D.Diag(clang::diag::err_drv_no_such_file) << Path.str();
   return false;
 }

Added: cfe/trunk/test/Driver/Inputs/cl-libs/cl-test.lib
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/cl-libs/cl-test.lib?rev=211189&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/cl-inputs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-inputs.c?rev=211189&r1=211188&r2=211189&view=diff
==
--- cfe/trunk/test/Driver/cl-inputs.c (original)
+++ cfe/trunk/test/Driver/cl-inputs.c Wed Jun 18 12:21:50 2014
@@ -40,4 +40,13 @@
 // RUN: %clang_cl -### /Tc - 2>&1 | FileCheck -check-prefix=STDINTc %s
 // STDINTc: "-x" "c"
 
+// RUN: env LIB=%S/Inputs/cl-libs %clang_cl -### -- %s cl-test.lib 2>&1 | 
FileCheck -check-prefix=LIBINPUT %s
+// LIBINPUT: "link.exe"
+// LIBINPUT: "cl-test.lib"
+
+// RUN: env LIB=%S/Inputs/cl-libs %clang_cl -### -- %s cl-test2.lib 2>&1 | 
FileCheck -check-prefix=LIBINPUT2 %s
+// LIBINPUT2: error: no such file or directory: 'cl-test2.lib'
+// LIBINPUT2: "link.exe"
+// LIBINPUT2-NOT: "cl-test2.lib"
+
 void f();


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Warren Hunt

Comment at: lib/Headers/Intrin.h:227
@@ -226,3 +226,3 @@
 static __inline__
-long __cdecl _InterlockedExchange(long volatile *_Target, long _Value);
 static __inline__

I don't see why it was necessary to get rid of __cdecl.  Also, Now that the 
definition is gone it shouldn't be static __inline__ anymore.

http://reviews.llvm.org/D4182



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Teach CC1 to dump module dependencies to a directory

2014-06-18 Thread Ben Langmuir

> On Jun 18, 2014, at 9:11 AM, Argyrios Kyrtzidis  wrote:
> 
>> 
>> On Jun 18, 2014, at 1:08 AM, Justin Bogner  wrote:
>> 
>> Thanks for the feedback!
>> 
>> Argyrios Kyrtzidis  writes:
>>> Thank you for your work on this.
>>> 
>>> Some high level comments first; the way ModuleDependencyCollector is
>>> getting hooked up, results in:
>>> 
>>> - If no module needs building (because module cache has it) no module
>>> dependency is getting written out
>> 
>> I realize this, but as far as I can tell there isn't really a practical
>> way to get all of the module dependencies except for when we actually
>> create a module. Unless there's a way to extract this information from
>> an imported ModuleFile that I've missed, I think we need to collect this
>> information as we parse the AST to build a module in the first place.
>> 
>> If there is a more reliable way to do this, I'm all ears. I should
>> mention though, for the purposes of getting more useful crash reports
>> with modules this limitation isn't very important. Notably, it's useful
>> to collect the .pcm files anyway, and using a fresh cache directory is a
>> very simple way to do that.
>> 
>>> - It doesn’t hook in the top level module, e.g. if I have "@import
>>> Darwin;” then no module dependency is written out even if the module
>>> cache is empty.
>> 
>> This seems like a bigger problem, and I don't really understand it.
>> Where is the module built? I'm pretty convinced that the place I've
>> hooked into is the only one that creates a CompilerInstance with
>> BuildingModule set to true…
> 
> Ben, could you help out on hooking up ModuleDependencyCollector in a way that 
> will address the above ?

Sure!  The problem is that the first time we come to attempt loading a 
top-level module (before it is compiled), we will be here and not attach 
anything since ModuleDepCollector hasn’t been filled in yet.
> +if (ModuleDepCollector)
> +  ModuleDepCollector->attachToASTReader(*ModuleManager);

If you call ModuleDepCollector = getModuleDepCollector() before that if, it 
works for me.

Ben

> 
>> 
>>> Some nitpicks:
>>> 
>>> @@ -105,6 +105,9 @@ class CompilerInstance : public ModuleLoader {
>>>  /// \brief The ASTReader, if one exists.
>>>  IntrusiveRefCntPtr ModuleManager;
>>> 
>>> +  /// \brief The module dependency collector for crashdumps
>>> +  std::shared_ptr ModuleDepCollector;
>>> +
>>>  /// \brief The dependency file generator.
>>>  std::unique_ptr TheDependencyFileGenerator;
>>> 
>>> Is there a policy to avoid IntrusiveRefCntPtr ?
>> 
>> Since we're using C++11 now, I just assumed we'd be migrating to
>> shared_ptr where appropriate in modern code. I can change it to
>> IntrusiveRefCntPtr if you like, but I do think shared_ptr is appropriate
>> here.
> 
> That’s fine; In general IntrusiveRefCntPtr still has the advantage that it is 
> pointer sized.
> 
>> 
>>> +/// Collects the dependencies for imported modules into a directory.  Users
>>> +/// should attach to the AST reader whenever a module is loaded.
>>> +class ModuleDependencyCollector {
>>> +  StringRef DestDir;
>>> 
>>> Use std::string here.
>> 
>> Sure.
>> 
>>> +  void reportError() { HasErrors = true; }
>>> 
>>> Name is a bit misleading, how about "setHasErrors()” ?
>> 
>> Good idea.
>> 
>>> +llvm::error_code ModuleDependencyListener::copyToRoot(StringRef Src) {
>>> +  using namespace llvm::sys;
>>> +  SmallString<256> Dest = Collector.getDest();
>>> +  path::append(Dest, path::relative_path(Src));
>>> 
>>> Do we need to turn Src into an absolute path first, in case it’s
>>> relative to the current directory ?
>> 
>> Yes, I think so.
>> 
>>> +  if (llvm::error_code EC = fs::copy_file(Src, Dest.str()))
>>> +return EC;
>>> 
>>> Do you have a separate patch that introduces copy_file ?
>> 
>> Oops, forgot to attach that!
>> 
>> Updated patches attached.
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: r211031 - [C++1z] Implement N4051: 'typename' is permitted instead of 'class' when declaring a template template parameter.

2014-06-18 Thread Jordan Rose

On Jun 16, 2014, at 8:51 , Richard Smith  wrote:

> +def CXXPre1zCompat : DiagGroup<"c++98-c++11-c++14-compat">;
> +def CXXPre1zCompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
> +   [CXXPre1zCompat]>;

I'm not happy with this warning name. Can we say the *compat options are just 
the newest version? c++14-compat?

Alternately, we could have backwards names and forwards names: c++1z-compat for 
forwards compatibility warnings and pre-c++1z-compat for backwards 
compatibility warnings?

Jordan
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211177 - Driver: correct the backend option spelling

2014-06-18 Thread Saleem Abdulrasool
Author: compnerd
Date: Wed Jun 18 11:52:24 2014
New Revision: 211177

URL: http://llvm.org/viewvc/llvm-project?rev=211177&view=rev
Log:
Driver: correct the backend option spelling

The backend option does not have an '-enable' prefix.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/arm-long-calls.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=211177&r1=211176&r2=211177&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jun 18 11:52:24 2014
@@ -3479,7 +3479,7 @@ void Clang::ConstructJob(Compilation &C,
  options::OPT_mno_long_calls)) {
   if (A->getOption().matches(options::OPT_mlong_calls)) {
 CmdArgs.push_back("-backend-option");
-CmdArgs.push_back("-enable-arm-long-calls");
+CmdArgs.push_back("-arm-long-calls");
   }
 }
   }

Modified: cfe/trunk/test/Driver/arm-long-calls.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-long-calls.c?rev=211177&r1=211176&r2=211177&view=diff
==
--- cfe/trunk/test/Driver/arm-long-calls.c (original)
+++ cfe/trunk/test/Driver/arm-long-calls.c Wed Jun 18 11:52:24 2014
@@ -7,9 +7,9 @@
 // RUN: %clang -target armv7-eabi -### -mlong-calls -mno-long-calls %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-NO-LONG-CALLS
 
-// CHECK-DEFAULT-NOT: "-backend-option" "-enable-arm-long-calls"
+// CHECK-DEFAULT-NOT: "-backend-option" "-arm-long-calls"
 
-// CHECK-LONG-CALLS: "-backend-option" "-enable-arm-long-calls"
+// CHECK-LONG-CALLS: "-backend-option" "-arm-long-calls"
 
-// CHECK-NO-LONG-CALLS-NOT: "-backend-option" "-enable-arm-long-calls"
+// CHECK-NO-LONG-CALLS-NOT: "-backend-option" "-arm-long-calls"
 


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] CodeGen: Don't emit a thread-wrapper if we can't touch the backing variable

2014-06-18 Thread David Majnemer
Ping.

http://reviews.llvm.org/D4109



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Move the calling of emitTargetMD() later.

2014-06-18 Thread Rafael Ávila de Espíndola
Alp Toker changed how we handled mangled names last, he is probably the correct 
person to review this.


Comment at: lib/CodeGen/CodeGenModule.cpp:3250
@@ -3252,4 +3249,3 @@
 
-  for (llvm::DenseMap::iterator
- I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) {
+  for (auto I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) {
 const Decl *D = I->first;

Can this use a range loop. If so, please commit that as a first independent 
improvement.

http://reviews.llvm.org/D4176



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Teach CC1 to dump module dependencies to a directory

2014-06-18 Thread Argyrios Kyrtzidis

> On Jun 18, 2014, at 1:08 AM, Justin Bogner  wrote:
> 
> Thanks for the feedback!
> 
> Argyrios Kyrtzidis  writes:
>> Thank you for your work on this.
>> 
>> Some high level comments first; the way ModuleDependencyCollector is
>> getting hooked up, results in:
>> 
>> - If no module needs building (because module cache has it) no module
>>  dependency is getting written out
> 
> I realize this, but as far as I can tell there isn't really a practical
> way to get all of the module dependencies except for when we actually
> create a module. Unless there's a way to extract this information from
> an imported ModuleFile that I've missed, I think we need to collect this
> information as we parse the AST to build a module in the first place.
> 
> If there is a more reliable way to do this, I'm all ears. I should
> mention though, for the purposes of getting more useful crash reports
> with modules this limitation isn't very important. Notably, it's useful
> to collect the .pcm files anyway, and using a fresh cache directory is a
> very simple way to do that.
> 
>> - It doesn’t hook in the top level module, e.g. if I have "@import
>>  Darwin;” then no module dependency is written out even if the module
>>  cache is empty.
> 
> This seems like a bigger problem, and I don't really understand it.
> Where is the module built? I'm pretty convinced that the place I've
> hooked into is the only one that creates a CompilerInstance with
> BuildingModule set to true…

Ben, could you help out on hooking up ModuleDependencyCollector in a way that 
will address the above ?

> 
>> Some nitpicks:
>> 
>> @@ -105,6 +105,9 @@ class CompilerInstance : public ModuleLoader {
>>   /// \brief The ASTReader, if one exists.
>>   IntrusiveRefCntPtr ModuleManager;
>> 
>> +  /// \brief The module dependency collector for crashdumps
>> +  std::shared_ptr ModuleDepCollector;
>> +
>>   /// \brief The dependency file generator.
>>   std::unique_ptr TheDependencyFileGenerator;
>> 
>> Is there a policy to avoid IntrusiveRefCntPtr ?
> 
> Since we're using C++11 now, I just assumed we'd be migrating to
> shared_ptr where appropriate in modern code. I can change it to
> IntrusiveRefCntPtr if you like, but I do think shared_ptr is appropriate
> here.

That’s fine; In general IntrusiveRefCntPtr still has the advantage that it is 
pointer sized.

> 
>> +/// Collects the dependencies for imported modules into a directory.  Users
>> +/// should attach to the AST reader whenever a module is loaded.
>> +class ModuleDependencyCollector {
>> +  StringRef DestDir;
>> 
>> Use std::string here.
> 
> Sure.
> 
>> +  void reportError() { HasErrors = true; }
>> 
>> Name is a bit misleading, how about "setHasErrors()” ?
> 
> Good idea.
> 
>> +llvm::error_code ModuleDependencyListener::copyToRoot(StringRef Src) {
>> +  using namespace llvm::sys;
>> +  SmallString<256> Dest = Collector.getDest();
>> +  path::append(Dest, path::relative_path(Src));
>> 
>> Do we need to turn Src into an absolute path first, in case it’s
>> relative to the current directory ?
> 
> Yes, I think so.
> 
>> +  if (llvm::error_code EC = fs::copy_file(Src, Dest.str()))
>> +return EC;
>> 
>> Do you have a separate patch that introduces copy_file ?
> 
> Oops, forgot to attach that!
> 
> Updated patches attached.
> 
> ___
> cfe-commits mailing list
> cfe-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Inherit dll attributes to static locals

2014-06-18 Thread Hans Wennborg
Closed by commit rL211173 (authored by @hans).

http://reviews.llvm.org/D4136

Files:
  cfe/trunk/include/clang/Sema/SemaInternal.h
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/CodeGenCXX/dllexport.cpp
  cfe/trunk/test/CodeGenCXX/dllimport.cpp
Index: cfe/trunk/test/CodeGenCXX/dllexport.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp
@@ -72,6 +72,22 @@
 // GNU-DAG: @ExternalAutoTypeGlobal  = dllexport global %struct.External zeroinitializer, align 4
 __declspec(dllexport) auto ExternalAutoTypeGlobal = External();
 
+int f();
+// MSC-DAG: @"\01?x@?0??nonInlineStaticLocalsFunc@@YAHXZ@4HA" = internal {{(unnamed_addr )*}}global i32 0
+// MSC-DAG: @"\01?$S1@?0??nonInlineStaticLocalsFunc@@YAHXZ@4IA" = internal {{(unnamed_addr )*}}global i32 0
+int __declspec(dllexport) nonInlineStaticLocalsFunc() {
+  static int x = f();
+  return x++;
+};
+
+// MSC-DAG: @"\01?x@?1??inlineStaticLocalsFunc@@YAHXZ@4HA" = weak_odr dllexport global i32 0
+// MSC-DAG: @"\01??_B?1??inlineStaticLocalsFunc@@YAHXZ@51" = weak_odr dllexport global i32 0
+// Note: MinGW doesn't seem to export the static local here.
+inline int __declspec(dllexport) inlineStaticLocalsFunc() {
+  static int x = f();
+  return x++;
+}
+
 
 
 //===--===//
Index: cfe/trunk/test/CodeGenCXX/dllimport.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp
@@ -85,6 +85,15 @@
 namespace ns { __declspec(dllimport) int ExternalGlobal; }
 USEVAR(ns::ExternalGlobal)
 
+int f();
+// MO1-DAG: @"\01?x@?1??inlineStaticLocalsFunc@@YAHXZ@4HA" = available_externally dllimport global i32 0
+// MO1-DAG: @"\01??_B?1??inlineStaticLocalsFunc@@YAHXZ@51" = available_externally dllimport global i32 0
+inline int __declspec(dllimport) inlineStaticLocalsFunc() {
+  static int x = f();
+  return x++;
+};
+USE(inlineStaticLocalsFunc);
+
 
 
 //===--===//
Index: cfe/trunk/include/clang/Sema/SemaInternal.h
===
--- cfe/trunk/include/clang/Sema/SemaInternal.h
+++ cfe/trunk/include/clang/Sema/SemaInternal.h
@@ -74,6 +74,18 @@
 
   Var->markUsed(SemaRef.Context);
 }
+
+/// Return a DLL attribute from the declaration.
+inline InheritableAttr *getDLLAttr(Decl *D) {
+  assert(!(D->hasAttr() && D->hasAttr()) &&
+ "A declaration cannot be both dllimport and dllexport.");
+  if (auto *Import = D->getAttr())
+return Import;
+  if (auto *Export = D->getAttr())
+return Export;
+  return nullptr;
+}
+
 }
 
 #endif
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -201,6 +201,13 @@
   if (D.getTLSKind())
 CGM.setTLSMode(GV, D);
 
+  if (D.isExternallyVisible()) {
+if (D.hasAttr())
+  GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
+else if (D.hasAttr())
+  GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
+  }
+
   // Make sure the result is of the correct type.
   unsigned ExpectedAddrSpace = CGM.getContext().getTargetAddressSpace(Ty);
   if (AddrSpace != ExpectedAddrSpace) {
Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1425,12 +1425,13 @@
   Out.flush();
 }
 
-// Create the guard variable with a zero-initializer.  Just absorb linkage
-// and visibility from the guarded variable.
+// Create the guard variable with a zero-initializer. Just absorb linkage,
+// visibility and dll storage class from the guarded variable.
 GI->Guard =
 new llvm::GlobalVariable(CGM.getModule(), GuardTy, false,
  GV->getLinkage(), Zero, GuardName.str());
 GI->Guard->setVisibility(GV->getVisibility());
+GI->Guard->setDLLStorageClass(GV->getDLLStorageClass());
   } else {
 assert(GI->Guard->getLinkage() == GV->getLinkage() &&
"static local from the same function had different linkage");
Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -4347,17 +4347,6 @@
   }
 }
 
-/// \brief Return a DLL attribute from the declaration.
-static InheritableAttr *getDLLAttr(Decl *D) {
-  assert(!(D->hasAttr() && D->hasAttr()) &&
- "A declaration cannot be both dllimport and dllexport.");
-  if

r211173 - Inherit dll attributes to static locals

2014-06-18 Thread Hans Wennborg
Author: hans
Date: Wed Jun 18 10:55:13 2014
New Revision: 211173

URL: http://llvm.org/viewvc/llvm-project?rev=211173&view=rev
Log:
Inherit dll attributes to static locals

This makes us handle static locals in exported/imported functions correctly.

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

Modified:
cfe/trunk/include/clang/Sema/SemaInternal.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/include/clang/Sema/SemaInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaInternal.h?rev=211173&r1=211172&r2=211173&view=diff
==
--- cfe/trunk/include/clang/Sema/SemaInternal.h (original)
+++ cfe/trunk/include/clang/Sema/SemaInternal.h Wed Jun 18 10:55:13 2014
@@ -74,6 +74,18 @@ inline void MarkVarDeclODRUsed(VarDecl *
 
   Var->markUsed(SemaRef.Context);
 }
+
+/// Return a DLL attribute from the declaration.
+inline InheritableAttr *getDLLAttr(Decl *D) {
+  assert(!(D->hasAttr() && D->hasAttr()) &&
+ "A declaration cannot be both dllimport and dllexport.");
+  if (auto *Import = D->getAttr())
+return Import;
+  if (auto *Export = D->getAttr())
+return Export;
+  return nullptr;
+}
+
 }
 
 #endif

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=211173&r1=211172&r2=211173&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jun 18 10:55:13 2014
@@ -201,6 +201,13 @@ CodeGenFunction::CreateStaticVarDecl(con
   if (D.getTLSKind())
 CGM.setTLSMode(GV, D);
 
+  if (D.isExternallyVisible()) {
+if (D.hasAttr())
+  GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
+else if (D.hasAttr())
+  GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
+  }
+
   // Make sure the result is of the correct type.
   unsigned ExpectedAddrSpace = CGM.getContext().getTargetAddressSpace(Ty);
   if (AddrSpace != ExpectedAddrSpace) {

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=211173&r1=211172&r2=211173&view=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Jun 18 10:55:13 2014
@@ -1425,12 +1425,13 @@ void MicrosoftCXXABI::EmitGuardedInit(Co
   Out.flush();
 }
 
-// Create the guard variable with a zero-initializer.  Just absorb linkage
-// and visibility from the guarded variable.
+// Create the guard variable with a zero-initializer. Just absorb linkage,
+// visibility and dll storage class from the guarded variable.
 GI->Guard =
 new llvm::GlobalVariable(CGM.getModule(), GuardTy, false,
  GV->getLinkage(), Zero, GuardName.str());
 GI->Guard->setVisibility(GV->getVisibility());
+GI->Guard->setDLLStorageClass(GV->getDLLStorageClass());
   } else {
 assert(GI->Guard->getLinkage() == GV->getLinkage() &&
"static local from the same function had different linkage");

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=211173&r1=211172&r2=211173&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jun 18 10:55:13 2014
@@ -9097,6 +9097,18 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
 
   checkAttributesAfterMerging(*this, *VD);
 
+  // Static locals inherit dll attributes from their function.
+  if (VD->isStaticLocal()) {
+if (FunctionDecl *FD =
+dyn_cast(VD->getParentFunctionOrMethod())) {
+  if (Attr *A = getDLLAttr(FD)) {
+auto *NewAttr = cast(A->clone(getASTContext()));
+NewAttr->setInherited(true);
+VD->addAttr(NewAttr);
+  }
+}
+  }
+
   // Imported static data members cannot be defined out-of-line.
   if (const DLLImportAttr *IA = VD->getAttr()) {
 if (VD->isStaticDataMember() && VD->isOutOfLine() &&

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=211173&r1=211172&r2=211173&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jun 18 10:55:13 2014
@@ -4347,17 +4347,6 @@ static void CheckAbstractClassUsage(Abst
   }
 }
 
-/// \brief Return a DLL attribute from the declaration

Re: [PATCH] CodeGen: improve ms instrincics support

2014-06-18 Thread Saleem Abdulrasool
Address comments from rnk.

http://reviews.llvm.org/D4182

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/Intrin.h
  test/CodeGen/ms-intrinsics.c
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -683,9 +683,12 @@
 LANGBUILTIN(__debugbreak, "v",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__va_start,   "vc**.", "nt", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange, "LiLiD*LiLi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedCompareExchangePointer, "v*v*D*v*v*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedIncrement, "LiLiD*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedDecrement, "LiLiD*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
 
 // C99 library functions
 // C99 stdlib.h
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1516,6 +1516,34 @@
 E->getArg(0), true);
   case Builtin::BI__noop:
 return RValue::get(nullptr);
+  case Builtin::BI_InterlockedExchange:
+  case Builtin::BI_InterlockedExchangePointer: {
+return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E);
+  }
+  case Builtin::BI_InterlockedCompareExchangePointer: {
+llvm::Type *RTy;
+llvm::IntegerType *IntType =
+  IntegerType::get(getLLVMContext(),
+   getContext().getTypeSize(E->getType()));
+llvm::Type *IntPtrType = IntType->getPointerTo();
+
+llvm::Value *Destination =
+  Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), IntPtrType);
+
+llvm::Value *Exchange = EmitScalarExpr(E->getArg(1));
+RTy = Exchange->getType();
+Exchange = Builder.CreatePtrToInt(Exchange, CGM.Int32Ty);
+
+llvm::Value *Comparend =
+  Builder.CreatePtrToInt(EmitScalarExpr(E->getArg(2)), CGM.Int32Ty);
+
+Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+Exchange,
+SequentiallyConsistent,
+SequentiallyConsistent);
+Result = Builder.CreateIntToPtr(Result, RTy);
+return RValue::get(Result);
+  }
   case Builtin::BI_InterlockedCompareExchange: {
 AtomicCmpXchgInst *CXI = Builder.CreateAtomicCmpXchg(
 EmitScalarExpr(E->getArg(0)),
Index: lib/Headers/Intrin.h
===
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -224,7 +224,7 @@
 static __inline__
 short _InterlockedDecrement16(short volatile *_Addend);
 static __inline__
-long __cdecl _InterlockedExchange(long volatile *_Target, long _Value);
+long _InterlockedExchange(long volatile *_Target, long _Value);
 static __inline__
 short _InterlockedExchange16(short volatile *_Target, short _Value);
 static __inline__
@@ -785,22 +785,12 @@
   __atomic_exchange(_Target, &_Value, &_Value, 0);
   return _Value;
 }
-static __inline__ long __attribute__((__always_inline__, __nodebug__))
-_InterlockedExchange(long volatile *_Target, long _Value) {
-  __atomic_exchange(_Target, &_Value, &_Value, 0);
-  return _Value;
-}
 #ifdef __x86_64__
 static __inline__ __int64 __attribute__((__always_inline__, __nodebug__))
 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value) {
   __atomic_exchange(_Target, &_Value, &_Value, 0);
   return _Value;
 }
-static __inline__ void *__attribute__((__always_inline__, __nodebug__))
-_InterlockedExchangePointer(void *volatile *_Target, void *_Value) {
-  __atomic_exchange(_Target, &_Value, &_Value, 0);
-  return _Value;
-}
 #endif
 /**\
 |* Interlocked Compare Exchange
@@ -817,14 +807,6 @@
   __atomic_compare_exchange(_Destination, &_Comparand, &_Exchange, 0, 0, 0);
   return _Comparand;
 }
-#ifdef __x86_64__
-static __inline__ void *__attribute__((__always_inline__, __nodebug__))
-_InterlockedCompareExchangePointer(void *volatile *_Destination,
-   void *_Exchange, void *_Comparand) {
-  __atomic_compare_exchange(_Destination, &_Comparand, &_Exchange, 0, 0, 0);
-  return _Comparand;
-}
-#endif
 static __inline__ __int64 __attribute__((__always_inline__, __nodebug__))
 _InterlockedCompareExchange64(__int64 volatile *_Destination,
   __int64 _Exchange, __int64 _Comparand) {
Index: test/CodeGen/ms-intrinsics.c
===
--- /dev/null
+++ test/CodeGen/ms-intrinsics.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple i686--windows -fms-compatibility -Oz -emit-llv

Re: [PATCH] Inherit dll attributes to static locals

2014-06-18 Thread Nico Rieck
>>! In D4136#10, @hans wrote:
> Nico: does the new version of the patch look ok to you?

LGTM


Comment at: lib/Sema/SemaDecl.cpp:9108
@@ -9107,1 +9107,3 @@
 
+  // Static locals inherit dll attributes from their function.
+  if (VD->isStaticLocal()) {

Reid Kleckner wrote:
> Hans Wennborg wrote:
> > Reid Kleckner wrote:
> > > Should this go before checkAttributesAfterMerging?  Consider this 
> > > obnoxious test case:
> > >   int f();
> > >   inline __declspec(dllexport) int g() {
> > > static __declspec(dllimport) int x = f();
> > > return x;
> > >   }
> > Local variables cannot have explicit dll attributes. They can only get them 
> > by inheriting from the function they're part of, so calling 
> > checkAttributesAfterMerging to check up on the attribute we just added 
> > seems redundant.
> OK.  I assume this is covered by Nico's extensive test cases.  :)
Yup, this is handled by requiring external linkage.

http://reviews.llvm.org/D4136



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Division by zero

2014-06-18 Thread Anders Rönnholm
Changes according to comments. 

I'm pretty sure PVS-Studio does not have this checker, this bug has been seen 
in production code.

//Anders


Från: Jordan Rose [jordan_r...@apple.com]
Skickat: den 16 juni 2014 18:39
Till: Anders Rönnholm
Cc: cfe-commits@cs.uiuc.edu; Daniel Marjamäki
Ämne: Re: [PATCH] Division by zero

On Jun 5, 2014, at 5:16 , Anders Rönnholm 
mailto:anders.ronnh...@evidente.se>> wrote:

Hi Jordan,

New patch and some comments.

+inline void inline_func3(int x) {
+  var = 77 / x;
+}
+void ok_inline(int x) {
+  var = 77 / x;
+  inline_func3(x);
+  if (x==0){}
+}

This is an example where we should still be warning. Why aren't we?

It doesn't warn here because blockid is in the value and not the key as it 
should. I have made a set of symbol-block-frame as you suggested and that fixes 
this problem.


+// RUN: %clang_cc1 -analyze -analyzer-checker=core.DivideZero2 
-analyzer-output=text -verify %s

We should never be running path-sensitive checks without the rest of the core 
checkers.

There is a small problem here. It looks like the DivideZero checker makes the 
assumtion that because it can't see that a variable is zero then it's not zero 
so all variables in our tests have the range reg_$0 : { [-2147483648, -1], 
[1, 2147483647] }. I have removed the range check in my checker to make it work 
otherwise i would have to change the DivideZero checker.

Hm. The important thing is that a variable is zero before the division; in the 
absence of this checker, it's a reasonable assumption that it's zero if we made 
it past the division. Would it make sense to step back through ExplodedNodes 
instead until we found a ProgramPoint before the division statement itself, and 
then look at the value of the variable in that state?


+  const ZeroState *ZS = C.getState()->get(SR);
+  return (ZS && *ZS == ZeroState(C.getBlockID(), C.getStackFrame()));

...now I'm wondering about the wisdom of using a map for this. What if the same 
symbol is constrained in two stack frames? Would it make more sense to keep 
around a set of symbol-block-frame triples, rather than a map from symbols to 
block/frame pairs?

Or can this not happen because a value can only be used once along a certain 
path before it is constrained to be non-zero?

Changed to a set of symbol-block-frame triples to make the above example work.


+def DivZeroChecker2 : Checker<"DivideZero2">,
+  HelpText<"Check for division by variable that is later compared against 0. 
Either the comparison is useless or there is division by zero.">,
+  DescFile<"DivZeroChecker2.cpp">;
+

I'm not sure this is really a core checker, since it's safe to run the analyzer 
without it. But we don't have a category for "useful C checks that should be on 
by default" yet. Anton was looking at reorganizing the categories, but the 
problem is that everything outside of "alpha" is something people expect to be 
able to rely on when using scan-build.

Any ideas for this particular checker, or for the general issue?

I ok with having it as an alpha, or something else. I just put it in core since 
the other DivideZero checker is there.

Let's put it in alpha for now.

Code comments:

+class DivZeroChecker2
+: public Checker, check::BranchCondition,
+ check::EndFunction> {

Since we're not doing the normal divide-by-zero check in this checker, let's 
name it something else. "TestAfterDivideChecker", maybe?


+  DivZeroMapTy DivZeroes = C.getState()->get();
+  if (DivZeroes.isEmpty())
+return false;
+
+  for (llvm::ImmutableSet::iterator I = DivZeroes.begin(),
+   E = DivZeroes.end();
+   I != E; ++I) {
+if (*I == ZeroState(SR, C.getBlockID(), C.getStackFrame()))
+  return true;
+  }
+  return false;

This whole thing can be simplified quite a bit:

ZeroState ZS(SR, C.getBlockID(), C.getStackFrame());
return C.getState()->contains(ZS);


...and other than that it's looking pretty good! Has this checker found any 
real bugs that you know of? (Does PVS-Studio have a similar checker?)

JordanIndex: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h	(revision 210244)
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h	(working copy)
@@ -174,8 +172,13 @@
 return Pred->getLocationContext()->getAnalysisDeclContext();
   }
 
-  /// \brief If the given node corresponds to a PostStore program point, retrieve
-  /// the location region as it was uttered in the code.
+  /// \brief Get the blockID.
+  unsigned getBlockID() const {
+return NB.getContext().getBlock()->getBlockID();
+  }
+
+  /// \brief If the given node corresponds to a PostStore program point,
+  /// retrieve the location region as it was uttered in the code.
   ///
   /// This utility can be useful for generating extensive di

Re: triples for baremetal

2014-06-18 Thread Renato Golin
On 17 June 2014 18:26, Tom Stellard  wrote:
> What does 'bare-metal' mean in the context of a triple?

My confusion here is that bare-metal == NO OS, rather than Unknown OS.

The former is an explicit statement, saying you don't (generally) have
shared libraries, systemcalls, etc. The latter can (but not
necessarily does) depend on the platform, since the "default"
behaviour could be to assume OS=Linux or whatever.

I don't think there's a use case today where that fails, but I never
liked the extensive use people make of the "default" behaviour. On
ARM, we tend to add "none" as in arm-none-eabi to enforce bare-metal
and strict EABI compatibility.

cheers,
--renato
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Fix/Improve SourceRange of explicitly defaulted members

2014-06-18 Thread Daniel Jasper
It happens e.g. in 
test/SemaTemplate/instantiate-default-assignment-operator.cpp. Not sure whether 
it is a bug or not. I think if the entire member is implicit, getLocation() 
delivers a somewhat reasonable location whereas getLocEnd() (or EndRangeLoc) is 
never set.

http://reviews.llvm.org/D4175



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Fix/Improve SourceRange of explicitly defaulted members

2014-06-18 Thread Richard Smith
When does the `!isValid` case happen? That sounds like it's probably a bug.

Anyway, LGTM.

http://reviews.llvm.org/D4175



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add a check to flag the usage of C-style casts (Google Style).

2014-06-18 Thread Alexander Kornienko
Reordered registration of the checks. Added a newline after CHECK-NOT.

http://reviews.llvm.org/D4189

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/CStyleCastsCheck.cpp
  clang-tidy/google/CStyleCastsCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  test/clang-tidy/c-style-casts.cpp
Index: clang-tidy/google/CMakeLists.txt
===
--- clang-tidy/google/CMakeLists.txt
+++ clang-tidy/google/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyGoogleModule
+  CStyleCastsCheck.cpp
   ExplicitConstructorCheck.cpp
   GoogleTidyModule.cpp
 
Index: clang-tidy/google/CStyleCastsCheck.cpp
===
--- /dev/null
+++ clang-tidy/google/CStyleCastsCheck.cpp
@@ -0,0 +1,50 @@
+//===--- CStyleCastsCheck.cpp - clang-tidy --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CStyleCastsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void CStyleCastsCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
+  Finder->addMatcher(
+  cStyleCastExpr(
+  // Filter out (EnumType)IntegerLiteral construct, which is generated
+  // for non-type template arguments of enum types.
+  // FIXME: Remove this once this is fixed in the AST.
+  unless(allOf(hasDestinationType(hasDeclaration(enumDecl())),
+   hasSourceExpression(integerLiteral().bind("cast"),
+  this);
+}
+
+void CStyleCastsCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *CastExpr = Result.Nodes.getNodeAs("cast");
+
+  // Ignore casts in macros for now.
+  if (CastExpr->getLocStart().isMacroID())
+return;
+
+  // Casting to void is an idiomatic way to mute "unused variable" and similar
+  // warnings.
+  if (CastExpr->getTypeAsWritten()->isVoidType())
+return;
+
+  diag(CastExpr->getLocStart(), "C-style casts are discouraged. Use "
+"static_cast/const_cast/reinterpret_cast "
+"instead.");
+}
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/google/CStyleCastsCheck.h
===
--- /dev/null
+++ clang-tidy/google/CStyleCastsCheck.h
@@ -0,0 +1,33 @@
+//===--- CStyleCastsCheck.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_GOOGLE_C_STYLE_CASTS_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_C_STYLE_CASTS_CHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// \brief Finds usages of C-style casts.
+///
+/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting
+/// Corresponding cpplint.py check name: 'readability/casting'.
+class CStyleCastsCheck : public ClangTidyCheck {
+public:
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_C_STYLE_CASTS_CHECK_H
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "CStyleCastsCheck.h"
 #include "ExplicitConstructorCheck.h"
 
 using namespace clang::ast_matchers;
@@ -23,6 +24,9 @@
 CheckFactories.addCheckFactory(
 "google-explicit-constructor",
 new ClangTidyCheckFactory());
+CheckFactories.addCheckFactory(
+"google-readability-casting",
+new ClangTidyCheckFactory());
   }
 };
 
Index: test/clang-tidy/c-style-casts.cpp
===
--- /dev/null
+++ test/clang-tidy/c-style-casts.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-tidy -checks=-*,google-readability-casting %s -- | FileCheck %s
+
+// CHECK-NOT: warning:
+
+bool g() { return false; }
+
+void f(int a, double b) {
+  int b1 = (int)b;
+  // CHECK: :[[@LINE-1

Re: [PATCH] Add a check to flag the usage of C-style casts (Google Style).

2014-06-18 Thread Alexander Kornienko

Comment at: clang-tidy/google/CMakeLists.txt:4
@@ -3,2 +3,3 @@
 add_clang_library(clangTidyGoogleModule
+  CStyleCastsCheck.cpp
   ExplicitConstructorCheck.cpp

Daniel Jasper wrote:
> I think the naming is not ideal. First, the "..Check" is mostly redundant 
> information, maybe remove that, at least for new checks. Second, it would be 
> good to verify what is being checked with c-style casts. So, maybe 
> DontUseCStyleCasts.cpp or AvoidCStyleCasts.cpp.
I see some value in using the "Check" suffix for checks: it makes class names 
nouns in a consistent way. I like it a bit more than using imperatives (e.g. 
UseOverride). The matter of the check can rarely be expressed using a single 
short imperative statement.

A few examples:

  * ArgumentCommentCheck checks that the correct argument name is used in the 
argument comment. I don't see a good alternative name in the imperative style 
(UseCorrectArgumentNameInArgumentComment?).
  * one could name a check NameLocalVariablesCorrectly or 
LocalVariableNamingCheck. The latter seems a better alternative to me (though, 
it's a matter of taste).
  * UseOverride check doesn't always ask you to "use override". It checks the 
correct usage of the virtual, override and final keywords on methods. In this 
case the name reflects the most frequent use case of the check (and is rather 
clear), but the name hints that this is the _only_ use case. An alternative 
name using noun notation could be more correct (but maybe a bit more bulky): 
VirtualOverrideFinalCheck or InheritanceSpecifierCheck.

That said, AvoidCStyleCasts (though, I would prefer AvoidCStyleCastsCheck) may 
be an appropriate name for the check in this patch.


Comment at: clang-tidy/google/CStyleCastsCheck.h:21
@@ +20,3 @@
+///
+/// 'readability/casting'
+/// 
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting

Daniel Jasper wrote:
> What is this?
This is the name of the corresponding check in cpplint.py. I've added a comment.


Comment at: clang-tidy/google/GoogleTidyModule.cpp:25
@@ -23,1 +24,3 @@
 CheckFactories.addCheckFactory(
+"google-readability-casting",
+new ClangTidyCheckFactory());

Daniel Jasper wrote:
> Maybe order alphabetically by check name?
Done.


Comment at: test/clang-tidy/c-style-casts.cpp:1
@@ +1,2 @@
+// RUN: clang-tidy -checks=-*,google-readability-casting %s -- | FileCheck %s
+

Daniel Jasper wrote:
> Maybe use check_clang_tidy_output.sh to decouple the check configuration.
This script brings a bit of convenience, but it adds a requirement to use shell 
for tests, which limits the environments where the tests can run. However, the 
other script - check_clang_tidy_fix.sh - brings significant value, as it 
reduces a lot of shell code duplication from the RUN lines in the tests.

So I'd avoid using check_clang_tidy_output.sh. I'm not sure we actually need 
it, maybe just for consistency in cases where we have tests both for output and 
for fixes.


Comment at: test/clang-tidy/c-style-casts.cpp:3
@@ +2,3 @@
+
+// CHECK-NOT: warning:
+bool g() { return false; }

Daniel Jasper wrote:
> Out of curiosity, why would there be a c-style cast here?
There's no c-style cast here. It's a utility function used below. The placement 
of the CHECK-NOT may be confusing though. I'll put a blank line here, so that 
it doesn't look like it relates to this function. We need the CHECK-NOT before 
the first CHECK as a generic measure to make the check more strict.

http://reviews.llvm.org/D4189



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Adam Strzelecki
Sorry somehow updating commit msg and uploading it here doesn't affect Summary 
at very top. So I had to edit it manually.

http://reviews.llvm.org/D4190



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Make clang-cl accept .lib inputs

2014-06-18 Thread Ehsan Akhgari
Hi,

Please review http://reviews.llvm.org/D4192.  It fixes
http://llvm.org/bugs/show_bug.cgi?id=20065.

Cheers,
--
Ehsan

___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Fix/Improve SourceRange of explicitly defaulted members

2014-06-18 Thread Daniel Jasper
Fall back to getLocation() if getEndLoc() returns an invalid source location 
(this fixes a few tests for the default copy operators). Also fix a test that 
seems to have relied on the incorrectly calculated ranges (is the fix right?).

http://reviews.llvm.org/D4175

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/Analysis/inlining/path-notes.cpp
  test/Misc/ast-dump-decl.cpp
  test/SemaTemplate/instantiate-default-assignment-operator.cpp
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -8418,7 +8418,9 @@
 return;
   }
 
-  SourceLocation Loc = Constructor->getLocation();
+  SourceLocation Loc = Constructor->getLocEnd().isValid()
+   ? Constructor->getLocEnd()
+   : Constructor->getLocation();
   Constructor->setBody(new (Context) CompoundStmt(Loc));
 
   Constructor->markUsed(Context);
@@ -8880,7 +8882,9 @@
 return;
   }
 
-  SourceLocation Loc = Destructor->getLocation();
+  SourceLocation Loc = Destructor->getLocEnd().isValid()
+   ? Destructor->getLocEnd()
+   : Destructor->getLocation();
   Destructor->setBody(new (Context) CompoundStmt(Loc));
   Destructor->markUsed(Context);
   MarkVTableUsed(CurrentLocation, ClassDecl);
@@ -9580,8 +9584,10 @@
   }
   
   // Our location for everything implicitly-generated.
-  SourceLocation Loc = CopyAssignOperator->getLocation();
-  
+  SourceLocation Loc = CopyAssignOperator->getLocEnd().isValid()
+   ? CopyAssignOperator->getLocEnd()
+   : CopyAssignOperator->getLocation();
+
   // Builds a DeclRefExpr for the "other" object.
   RefBuilder OtherRef(Other, OtherRefType);
 
@@ -9985,7 +9991,9 @@
  "Bad argument type of defaulted move assignment");
 
   // Our location for everything implicitly-generated.
-  SourceLocation Loc = MoveAssignOperator->getLocation();
+  SourceLocation Loc = MoveAssignOperator->getLocEnd().isValid()
+   ? MoveAssignOperator->getLocEnd()
+   : MoveAssignOperator->getLocation();
 
   // Builds a reference to the "other" object.
   RefBuilder OtherRef(Other, OtherRefType);
@@ -10122,8 +10130,9 @@
 
   if (!Invalid) {
 // Add a "return *this;"
-ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*this, Loc));
-
+ExprResult ThisObj =
+CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*this, Loc));
+
 StmtResult Return = BuildReturnStmt(Loc, ThisObj.get());
 if (Return.isInvalid())
   Invalid = true;
@@ -10299,10 +10308,12 @@
   << CXXCopyConstructor << Context.getTagDeclType(ClassDecl);
 CopyConstructor->setInvalidDecl();
   }  else {
+SourceLocation Loc = CopyConstructor->getLocEnd().isValid()
+ ? CopyConstructor->getLocEnd()
+ : CopyConstructor->getLocation();
 Sema::CompoundScopeRAII CompoundScope(*this);
-CopyConstructor->setBody(ActOnCompoundStmt(
-CopyConstructor->getLocation(), CopyConstructor->getLocation(), None,
-/*isStmtExpr=*/ false).getAs());
+CopyConstructor->setBody(
+ActOnCompoundStmt(Loc, Loc, None, /*isStmtExpr=*/false).getAs());
   }
 
   CopyConstructor->markUsed(Context);
@@ -10455,10 +10466,12 @@
   << CXXMoveConstructor << Context.getTagDeclType(ClassDecl);
 MoveConstructor->setInvalidDecl();
   }  else {
+SourceLocation Loc = MoveConstructor->getLocEnd().isValid()
+ ? MoveConstructor->getLocEnd()
+ : MoveConstructor->getLocation();
 Sema::CompoundScopeRAII CompoundScope(*this);
 MoveConstructor->setBody(ActOnCompoundStmt(
-MoveConstructor->getLocation(), MoveConstructor->getLocation(), None,
-/*isStmtExpr=*/ false).getAs());
+Loc, Loc, None, /*isStmtExpr=*/ false).getAs());
   }
 
   MoveConstructor->markUsed(Context);
Index: test/Analysis/inlining/path-notes.cpp
===
--- test/Analysis/inlining/path-notes.cpp
+++ test/Analysis/inlining/path-notes.cpp
@@ -2452,12 +2452,12 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:   
 // CHECK-NEXT:line105
-// CHECK-NEXT:col21
+// CHECK-NEXT:col53
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
 // CHECK-NEXT:line105
-// CHECK-NEXT:col28
+// CHECK-NEXT:col53
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:  
@@ -2469,20 +2469,20 @@
 // CHECK-NEXT:  location
 // CHECK-NEXT:  
 // CHECK-NEXT:   line105
-// CHECK-NEXT:   col21
+// CHECK-NEXT:   col53
 // CHECK-NEXT:   file0
 // CHECK-NEXT:  
 // CHECK-NEXT:  ranges
 // CHECK-NEXT:  
 // CHECK-NEXT:
 // CHECK-NEXT: 
 /

Re: [PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Daniel Jasper
All your diffs are identical and I still don't see a subversion revision number.

http://reviews.llvm.org/D4190



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Adam Strzelecki
Remove spaces after Before/After headers, sample is in the commit log.

http://reviews.llvm.org/D4190

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h

Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Adam Strzelecki
Added sample and proper SVN revision reference.

http://reviews.llvm.org/D4190

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h

Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Update Mozilla Style

2014-06-18 Thread Daniel Jasper
Any updates?

http://reviews.llvm.org/D2610



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Daniel Jasper
What is 71bd6fc3? Can you use subversion revisions?

What is the actual bug? We definitely need a test case as well..

http://reviews.llvm.org/D4190



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] clang-format: [JS] Fix function formatting

2014-06-18 Thread Adam Strzelecki
Hi djasper,

We should consume function identifier only when we are in braced list.

This fixes bug introduced in 71bd6fc3 that effectively disabled JS function
formatting.

http://reviews.llvm.org/D4190

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h

Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -905,11 +905,11 @@
   return false;
 }
 
-void UnwrappedLineParser::tryToParseJSFunction() {
+void UnwrappedLineParser::tryToParseJSFunction(bool BracedList) {
   nextToken();
 
-  // Consume function name.
-  if (FormatTok->is(tok::identifier))
+  // Consume function name if in braced list.
+  if (BracedList && FormatTok->is(tok::identifier))
   nextToken();
 
   if (FormatTok->isNot(tok::l_paren))
@@ -945,7 +945,7 @@
   do {
 if (Style.Language == FormatStyle::LK_JavaScript &&
 FormatTok->TokenText == "function") {
-  tryToParseJSFunction();
+  tryToParseJSFunction(true);
   continue;
 }
 switch (FormatTok->Tok.getKind()) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -101,7 +101,7 @@
   void parseObjCProtocol();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
-  void tryToParseJSFunction();
+  void tryToParseJSFunction(bool BracedList = false);
   void addUnwrappedLine();
   bool eof() const;
   void nextToken();
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Add a check to flag the usage of C-style casts (Google Style).

2014-06-18 Thread Daniel Jasper

Comment at: clang-tidy/google/CMakeLists.txt:4
@@ -3,2 +3,3 @@
 add_clang_library(clangTidyGoogleModule
+  CStyleCastsCheck.cpp
   ExplicitConstructorCheck.cpp

I think the naming is not ideal. First, the "..Check" is mostly redundant 
information, maybe remove that, at least for new checks. Second, it would be 
good to verify what is being checked with c-style casts. So, maybe 
DontUseCStyleCasts.cpp or AvoidCStyleCasts.cpp.


Comment at: clang-tidy/google/CStyleCastsCheck.h:21
@@ +20,3 @@
+///
+/// 'readability/casting'
+/// 
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting

What is this?


Comment at: clang-tidy/google/GoogleTidyModule.cpp:25
@@ -23,1 +24,3 @@
 CheckFactories.addCheckFactory(
+"google-readability-casting",
+new ClangTidyCheckFactory());

Maybe order alphabetically by check name?


Comment at: test/clang-tidy/c-style-casts.cpp:1
@@ +1,2 @@
+// RUN: clang-tidy -checks=-*,google-readability-casting %s -- | FileCheck %s
+

Maybe use check_clang_tidy_output.sh to decouple the check configuration.


Comment at: test/clang-tidy/c-style-casts.cpp:3
@@ +2,3 @@
+
+// CHECK-NOT: warning:
+bool g() { return false; }

Out of curiosity, why would there be a c-style cast here?

http://reviews.llvm.org/D4189



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [OPENMP] Codegen for threadprivate variables

2014-06-18 Thread Alexey Bataev
Michael, try updated patch. I fixed possible problems.

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

18 Июнь 2014 г. 13:31:56, Michael Wong писал:
> I kept getting an error in the build, which is directly traced back to this
> change:
> llvm[4]: Compiling CGDeclCXX.cpp for Debug+Asserts build
> /nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:
> In member function 'void
> clang::CodeGen::CodeGenModule::EmitCXXOMPThreadPrivateInitFunction(const
> clang::VarDecl&, llvm::Constant*, bool, bool)':
> /nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
> error: no matching function for call to
> 'llvm::FunctionType::get(llvm::PointerType*&,  list>, bool)'
>/*isVarArg*/
> false)->getPointerTo();
>  ^
> /nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
> note: candidates are:
> In file included from
> /nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/Constants.h:28:0,
>   from
> /nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/ConstantFolder.h:20,
>   from
> /nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/IRBuilder.h:22,
>   from
> /nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGBuilder.h:13,
>   from
> /nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h:17,
>   from
> /nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:14:
> /nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
> note: static llvm::FunctionType* llvm::FunctionType::get(llvm::Type*,
> llvm::ArrayRef, bool)
> static FunctionType *get(Type *Result,
>  ^
> /nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
> note:   no known conversion for argument 2 from ' initializer list>' to 'llvm::ArrayRef'
>
>
> I am going to try again.
>
> http://reviews.llvm.org/D4002
>
>

http://reviews.llvm.org/D4002



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [OPENMP] Codegen for threadprivate variables

2014-06-18 Thread Alexey Bataev

Michael, try updated patch. I fixed possible problems.

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

18 Июнь 2014 г. 13:31:56, Michael Wong писал:

I kept getting an error in the build, which is directly traced back to this
change:
llvm[4]: Compiling CGDeclCXX.cpp for Debug+Asserts build
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:
In member function 'void
clang::CodeGen::CodeGenModule::EmitCXXOMPThreadPrivateInitFunction(const
clang::VarDecl&, llvm::Constant*, bool, bool)':
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
error: no matching function for call to
'llvm::FunctionType::get(llvm::PointerType*&, , bool)'
   /*isVarArg*/
false)->getPointerTo();
 ^
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
note: candidates are:
In file included from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/Constants.h:28:0,
  from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/ConstantFolder.h:20,
  from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/IRBuilder.h:22,
  from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGBuilder.h:13,
  from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h:17,
  from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:14:
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
note: static llvm::FunctionType* llvm::FunctionType::get(llvm::Type*,
llvm::ArrayRef, bool)
static FunctionType *get(Type *Result,
 ^
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
note:   no known conversion for argument 2 from '' to 'llvm::ArrayRef'


I am going to try again.

http://reviews.llvm.org/D4002




___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] Add a check to flag the usage of C-style casts (Google Style).

2014-06-18 Thread Alexander Kornienko
Hi djasper,

Add a check to flag the usage of C-style casts, as per Google Style
Guide:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting

http://reviews.llvm.org/D4189

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/CStyleCastsCheck.cpp
  clang-tidy/google/CStyleCastsCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  test/clang-tidy/c-style-casts.cpp
Index: clang-tidy/google/CMakeLists.txt
===
--- clang-tidy/google/CMakeLists.txt
+++ clang-tidy/google/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyGoogleModule
+  CStyleCastsCheck.cpp
   ExplicitConstructorCheck.cpp
   GoogleTidyModule.cpp
 
Index: clang-tidy/google/CStyleCastsCheck.cpp
===
--- /dev/null
+++ clang-tidy/google/CStyleCastsCheck.cpp
@@ -0,0 +1,50 @@
+//===--- CStyleCastsCheck.cpp - clang-tidy --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CStyleCastsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void CStyleCastsCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
+  Finder->addMatcher(
+  cStyleCastExpr(
+  // Filter out (EnumType)IntegerLiteral construct, which is generated
+  // for non-type template arguments of enum types.
+  // FIXME: Remove this once this is fixed in the AST.
+  unless(allOf(hasDestinationType(hasDeclaration(enumDecl())),
+   hasSourceExpression(integerLiteral().bind("cast"),
+  this);
+}
+
+void CStyleCastsCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *CastExpr = Result.Nodes.getNodeAs("cast");
+
+  // Ignore casts in macros for now.
+  if (CastExpr->getLocStart().isMacroID())
+return;
+
+  // Casting to void is an idiomatic way to mute "unused variable" and similar
+  // warnings.
+  if (CastExpr->getTypeAsWritten()->isVoidType())
+return;
+
+  diag(CastExpr->getLocStart(), "C-style casts are discouraged. Use "
+"static_cast/const_cast/reinterpret_cast "
+"instead.");
+}
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/google/CStyleCastsCheck.h
===
--- /dev/null
+++ clang-tidy/google/CStyleCastsCheck.h
@@ -0,0 +1,33 @@
+//===--- CStyleCastsCheck.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_GOOGLE_C_STYLE_CASTS_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_C_STYLE_CASTS_CHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// \brief Finds usages of C-style casts.
+///
+/// 'readability/casting'
+/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting
+class CStyleCastsCheck : public ClangTidyCheck {
+public:
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_C_STYLE_CASTS_CHECK_H
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "CStyleCastsCheck.h"
 #include "ExplicitConstructorCheck.h"
 
 using namespace clang::ast_matchers;
@@ -21,6 +22,9 @@
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.addCheckFactory(
+"google-readability-casting",
+new ClangTidyCheckFactory());
+CheckFactories.addCheckFactory(
 "google-explicit-constructor",
 new ClangTidyCheckFactory());
   }
Index: test/clang-tidy/c-style-casts.cpp
===
--- /dev/null
+++ test/clang-tidy/c-style-casts.cpp
@@ -0,0 +1,23 @@
+// RUN: clang-tidy -checks=-*,google-readability-casting %s

[clang-tools-extra] r211154 - Move google-explicit-constructor check to a separate source file.

2014-06-18 Thread Alexander Kornienko
Author: alexfh
Date: Wed Jun 18 04:33:46 2014
New Revision: 211154

URL: http://llvm.org/viewvc/llvm-project?rev=211154&view=rev
Log:
Move google-explicit-constructor check to a separate source file.

Summary: No functional changes.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
  - copied, changed from r211150, 
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h
  - copied, changed from r211150, 
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.h
Removed:
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.h
Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/unittests/clang-tidy/GoogleModuleTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=211154&r1=211153&r2=211154&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Wed Jun 18 
04:33:46 2014
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyGoogleModule
+  ExplicitConstructorCheck.cpp
   GoogleTidyModule.cpp
 
   LINK_LIBS

Copied: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp 
(from r211150, clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp&p1=clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp&r1=211150&r2=211154&rev=211154&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Wed 
Jun 18 04:33:46 2014
@@ -1,4 +1,4 @@
-//===--- GoogleTidyModule.cpp - clang-tidy 
===//
+//===--- ExplicitConstructorCheck.cpp - clang-tidy 
===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,18 +7,11 @@
 //
 
//===--===//
 
-#include "GoogleTidyModule.h"
-#include "../ClangTidy.h"
-#include "../ClangTidyModule.h"
-#include "../ClangTidyModuleRegistry.h"
+#include "ExplicitConstructorCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Lex/PPCallbacks.h"
-#include "clang/Lex/Preprocessor.h"
-#include "llvm/Support/raw_ostream.h"
 
 using namespace clang::ast_matchers;
 
@@ -88,22 +81,5 @@ void ExplicitConstructorCheck::check(con
   << FixItHint::CreateInsertion(Loc, "explicit ");
 }
 
-class GoogleModule : public ClangTidyModule {
-public:
-  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
-CheckFactories.addCheckFactory(
-"google-explicit-constructor",
-new ClangTidyCheckFactory());
-  }
-};
-
-// Register the GoogleTidyModule using this statically initialized variable.
-static ClangTidyModuleRegistry::Add X("google-module",
-"Adds Google lint 
checks.");
-
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the GoogleModule.
-volatile int GoogleModuleAnchorSource = 0;
-
 } // namespace tidy
 } // namespace clang

Copied: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h 
(from r211150, clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.h)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h?p2=clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h&p1=clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.h&r1=211150&r2=211154&rev=211154&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.h (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h Wed 
Jun 18 04:33:46 2014
@@ -1,4 +1,4 @@
-//===--- GoogleTidyModule.h - clang-tidy *- C++ 
-*-===//
+//===--- ExplicitConstructorCheck.h - clang-tidy *- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 
//===-

Re: [PATCH] Fix/Improve SourceRange of explicitly defaulted members

2014-06-18 Thread Daniel Jasper
http://reviews.llvm.org/D4175

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/Misc/ast-dump-decl.cpp
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -8418,7 +8418,7 @@
 return;
   }
 
-  SourceLocation Loc = Constructor->getLocation();
+  SourceLocation Loc = Constructor->getLocEnd();
   Constructor->setBody(new (Context) CompoundStmt(Loc));
 
   Constructor->markUsed(Context);
@@ -8880,7 +8880,7 @@
 return;
   }
 
-  SourceLocation Loc = Destructor->getLocation();
+  SourceLocation Loc = Destructor->getLocEnd();
   Destructor->setBody(new (Context) CompoundStmt(Loc));
   Destructor->markUsed(Context);
   MarkVTableUsed(CurrentLocation, ClassDecl);
@@ -9580,7 +9580,7 @@
   }
   
   // Our location for everything implicitly-generated.
-  SourceLocation Loc = CopyAssignOperator->getLocation();
+  SourceLocation Loc = CopyAssignOperator->getLocEnd();
   
   // Builds a DeclRefExpr for the "other" object.
   RefBuilder OtherRef(Other, OtherRefType);
@@ -9985,7 +9985,7 @@
  "Bad argument type of defaulted move assignment");
 
   // Our location for everything implicitly-generated.
-  SourceLocation Loc = MoveAssignOperator->getLocation();
+  SourceLocation Loc = MoveAssignOperator->getLocEnd();
 
   // Builds a reference to the "other" object.
   RefBuilder OtherRef(Other, OtherRefType);
@@ -10122,8 +10122,9 @@
 
   if (!Invalid) {
 // Add a "return *this;"
-ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*this, Loc));
-
+ExprResult ThisObj =
+CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*this, Loc));
+
 StmtResult Return = BuildReturnStmt(Loc, ThisObj.get());
 if (Return.isInvalid())
   Invalid = true;
@@ -10301,7 +10302,7 @@
   }  else {
 Sema::CompoundScopeRAII CompoundScope(*this);
 CopyConstructor->setBody(ActOnCompoundStmt(
-CopyConstructor->getLocation(), CopyConstructor->getLocation(), None,
+CopyConstructor->getLocEnd(), CopyConstructor->getLocEnd(), None,
 /*isStmtExpr=*/ false).getAs());
   }
 
@@ -10457,7 +10458,7 @@
   }  else {
 Sema::CompoundScopeRAII CompoundScope(*this);
 MoveConstructor->setBody(ActOnCompoundStmt(
-MoveConstructor->getLocation(), MoveConstructor->getLocation(), None,
+MoveConstructor->getLocEnd(), MoveConstructor->getLocEnd(), None,
 /*isStmtExpr=*/ false).getAs());
   }
 
Index: test/Misc/ast-dump-decl.cpp
===
--- test/Misc/ast-dump-decl.cpp
+++ test/Misc/ast-dump-decl.cpp
@@ -133,6 +133,31 @@
 // CHECK:  CXXDestructorDecl{{.*}} ~TestCXXDestructorDecl 'void (void) noexcept'
 // CHECK-NEXT:   CompoundStmt
 
+// Test that the range of a defaulted members is computed correctly.
+// FIXME: This should include the "= default".
+class TestMemberRanges {
+public:
+  TestMemberRanges() = default;
+  TestMemberRanges(const TestMemberRanges &Other) = default;
+  TestMemberRanges(TestMemberRanges &&Other) = default;
+  ~TestMemberRanges() = default;
+  TestMemberRanges &operator=(const TestMemberRanges &Other) = default;
+  TestMemberRanges &operator=(TestMemberRanges &&Other) = default;
+};
+void SomeFunction() {
+  TestMemberRanges A;
+  TestMemberRanges B(A);
+  B = A;
+  A = static_cast(B);
+  TestMemberRanges C(static_cast(A));
+}
+// CHECK:  CXXConstructorDecl{{.*}} 
+// CHECK:  CXXConstructorDecl{{.*}} 
+// CHECK:  CXXConstructorDecl{{.*}} 
+// CHECK:  CXXDestructorDecl{{.*}} 
+// CHECK:  CXXMethodDecl{{.*}} 
+// CHECK:  CXXMethodDecl{{.*}} 
+
 class TestCXXConversionDecl {
   operator int() { return 0; }
 };
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[PATCH] Move google-explicit-constructor check to a separate source file.

2014-06-18 Thread Alexander Kornienko
Hi djasper,

No functional changes.

http://reviews.llvm.org/D4188

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/ExplicitConstructorCheck.cpp
  clang-tidy/google/ExplicitConstructorCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  clang-tidy/google/GoogleTidyModule.h
  unittests/clang-tidy/GoogleModuleTest.cpp
Index: clang-tidy/google/CMakeLists.txt
===
--- clang-tidy/google/CMakeLists.txt
+++ clang-tidy/google/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyGoogleModule
+  ExplicitConstructorCheck.cpp
   GoogleTidyModule.cpp
 
   LINK_LIBS
Index: clang-tidy/google/ExplicitConstructorCheck.cpp
===
--- clang-tidy/google/ExplicitConstructorCheck.cpp
+++ clang-tidy/google/ExplicitConstructorCheck.cpp
@@ -1,24 +1,17 @@
-//===--- GoogleTidyModule.cpp - clang-tidy ===//
+//===--- ExplicitConstructorCheck.cpp - clang-tidy ===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===--===//
 
-#include "GoogleTidyModule.h"
-#include "../ClangTidy.h"
-#include "../ClangTidyModule.h"
-#include "../ClangTidyModuleRegistry.h"
+#include "ExplicitConstructorCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Lex/PPCallbacks.h"
-#include "clang/Lex/Preprocessor.h"
-#include "llvm/Support/raw_ostream.h"
 
 using namespace clang::ast_matchers;
 
@@ -88,22 +81,5 @@
   << FixItHint::CreateInsertion(Loc, "explicit ");
 }
 
-class GoogleModule : public ClangTidyModule {
-public:
-  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
-CheckFactories.addCheckFactory(
-"google-explicit-constructor",
-new ClangTidyCheckFactory());
-  }
-};
-
-// Register the GoogleTidyModule using this statically initialized variable.
-static ClangTidyModuleRegistry::Add X("google-module",
-"Adds Google lint checks.");
-
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the GoogleModule.
-volatile int GoogleModuleAnchorSource = 0;
-
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/google/ExplicitConstructorCheck.h
===
--- clang-tidy/google/ExplicitConstructorCheck.h
+++ clang-tidy/google/ExplicitConstructorCheck.h
@@ -1,14 +1,14 @@
-//===--- GoogleTidyModule.h - clang-tidy *- C++ -*-===//
+//===--- ExplicitConstructorCheck.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_GOOGLE_GOOGLE_TIDY_MODULE_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_GOOGLE_TIDY_MODULE_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_EXPLICIT_CONSTRUCTOR_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_EXPLICIT_CONSTRUCTOR_CHECK_H
 
 #include "../ClangTidy.h"
 
@@ -28,4 +28,4 @@
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_GOOGLE_TIDY_MODULE_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_EXPLICIT_CONSTRUCTOR_CHECK_H
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -7,87 +7,16 @@
 //
 //===--===//
 
-#include "GoogleTidyModule.h"
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/PPCallbacks.h"
-#include "clang/Lex/Preprocessor.h"
-#include "llvm/Support/raw_ostream.h"
+#include "ExplicitConstructorCheck.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 
-void ExplicitConstructorCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(constructorDecl().bind("ctor"), this);
-}
-
-// Looks for the token matching the predicate and returns the range of the found
-// token including trailing whitespace.
-

Re: [PATCH] [OPENMP] Codegen for threadprivate variables

2014-06-18 Thread Michael Wong
I kept getting an error in the build, which is directly traced back to this
change:
llvm[4]: Compiling CGDeclCXX.cpp for Debug+Asserts build
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:
In member function 'void
clang::CodeGen::CodeGenModule::EmitCXXOMPThreadPrivateInitFunction(const
clang::VarDecl&, llvm::Constant*, bool, bool)':
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
error: no matching function for call to
'llvm::FunctionType::get(llvm::PointerType*&, , bool)'
  /*isVarArg*/
false)->getPointerTo();
^
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
note: candidates are:
In file included from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/Constants.h:28:0,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/ConstantFolder.h:20,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/IRBuilder.h:22,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGBuilder.h:13,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h:17,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:14:
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
note: static llvm::FunctionType* llvm::FunctionType::get(llvm::Type*,
llvm::ArrayRef, bool)
   static FunctionType *get(Type *Result,
^
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
note:   no known conversion for argument 2 from '' to 'llvm::ArrayRef'


I am going to try again.

http://reviews.llvm.org/D4002



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] [OPENMP] Codegen for threadprivate variables

2014-06-18 Thread Michael Wong
I kept getting an error in the build, which is directly traced back to this
change:
llvm[4]: Compiling CGDeclCXX.cpp for Debug+Asserts build
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:
In member function 'void
clang::CodeGen::CodeGenModule::EmitCXXOMPThreadPrivateInitFunction(const
clang::VarDecl&, llvm::Constant*, bool, bool)':
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
error: no matching function for call to
'llvm::FunctionType::get(llvm::PointerType*&, , bool)'
  /*isVarArg*/
false)->getPointerTo();
^
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:600:60:
note: candidates are:
In file included from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/Constants.h:28:0,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/ConstantFolder.h:20,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/IRBuilder.h:22,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGBuilder.h:13,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h:17,
 from
/nfs/terran/home/michaelw/clang-dev-new/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp:14:
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
note: static llvm::FunctionType* llvm::FunctionType::get(llvm::Type*,
llvm::ArrayRef, bool)
   static FunctionType *get(Type *Result,
^
/nfs/terran/home/michaelw/clang-dev-new/llvm/include/llvm/IR/DerivedTypes.h:105:24:
note:   no known conversion for argument 2 from '' to 'llvm::ArrayRef'


I am going to try again.


On Mon, Jun 16, 2014 at 12:52 AM, Alexey Bataev 
wrote:

> Ping
>
> http://reviews.llvm.org/D4002
>
>
>
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211149 - AArch64: re-enable tests that were looking for a non-existent backend.

2014-06-18 Thread Tim Northover
Author: tnorthover
Date: Wed Jun 18 03:37:28 2014
New Revision: 211149

URL: http://llvm.org/viewvc/llvm-project?rev=211149&view=rev
Log:
AArch64: re-enable tests that were looking for a non-existent backend.

In the final phase of the merge, I managed to disable a bunch of Clang
tests accidentally. Fortunately none of them seem to have broken in
the interim.

Modified:
cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
cfe/trunk/test/CodeGen/aarch64-neon-3v.c
cfe/trunk/test/CodeGen/aarch64-neon-across.c
cfe/trunk/test/CodeGen/aarch64-neon-extract.c
cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
cfe/trunk/test/CodeGen/aarch64-neon-fma.c
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
cfe/trunk/test/CodeGen/aarch64-neon-ldst-one.c
cfe/trunk/test/CodeGen/aarch64-neon-misc.c
cfe/trunk/test/CodeGen/aarch64-neon-perm.c
cfe/trunk/test/CodeGen/aarch64-neon-scalar-copy.c
cfe/trunk/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
cfe/trunk/test/CodeGen/aarch64-neon-shifts.c
cfe/trunk/test/CodeGen/aarch64-neon-tbl.c
cfe/trunk/test/CodeGen/aarch64-neon-vcombine.c
cfe/trunk/test/CodeGen/aarch64-neon-vget-hilo.c
cfe/trunk/test/CodeGen/aarch64-poly128.c
cfe/trunk/test/CodeGen/aarch64-poly64.c
cfe/trunk/test/CodeGen/arm64-crc32.c
cfe/trunk/test/CodeGen/arm64-scalar-test.c
cfe/trunk/test/CodeGen/arm64_crypto.c
cfe/trunk/test/CodeGen/arm64_neon_high_half.c
cfe/trunk/test/CodeGen/arm64_vMaxMin.c
cfe/trunk/test/CodeGen/arm64_vdupq_n_f64.c
cfe/trunk/test/CodeGen/arm64_vecCmpBr.c
cfe/trunk/test/CodeGen/arm64_vqmov.c
cfe/trunk/test/CodeGen/arm64_vrecps.c
cfe/trunk/test/CodeGen/arm64_vsli.c
cfe/trunk/test/CodeGen/arm64_vsri.c
cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp
cfe/trunk/test/CodeGenCXX/aarch64-neon.cpp
cfe/trunk/test/CodeGenCXX/int64_uint64.cpp

Modified: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-2velem.c?rev=211149&r1=211148&r2=211149&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c Wed Jun 18 03:37:28 2014
@@ -1,4 +1,4 @@
-// REQUIRES: arm64-registered-target
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -S -O3 
-o - %s | FileCheck %s
 
 // Test new aarch64 intrinsics and types

Modified: cfe/trunk/test/CodeGen/aarch64-neon-3v.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-3v.c?rev=211149&r1=211148&r2=211149&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-3v.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-3v.c Wed Jun 18 03:37:28 2014
@@ -1,4 +1,4 @@
-// REQUIRES: arm64-registered-target
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -S -O3 
-o - %s | FileCheck %s
 
 // Test new aarch64 intrinsics and types

Modified: cfe/trunk/test/CodeGen/aarch64-neon-across.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-across.c?rev=211149&r1=211148&r2=211149&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-across.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-across.c Wed Jun 18 03:37:28 2014
@@ -1,4 +1,4 @@
-// REQUIRES: arm64-registered-target
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
 // RUN:   -ffp-contract=fast -S -O3 -o - %s | FileCheck %s
 

Modified: cfe/trunk/test/CodeGen/aarch64-neon-extract.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-extract.c?rev=211149&r1=211148&r2=211149&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-extract.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-extract.c Wed Jun 18 03:37:28 2014
@@ -1,4 +1,4 @@
-// REQUIRES: arm64-registered-target
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
 // RUN:   -ffp-contract=fast -S -O3 -o - %s | FileCheck %s
 

Modified: cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c?rev=211149&r1=211148&r2=211149&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c Wed Jun 18 03:37:28 
2014
@@ -1,4 +1,4 @@
-// REQUIRES: arm64-registered-target
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -t

Re: [PATCH] Teach CC1 to dump module dependencies to a directory

2014-06-18 Thread Justin Bogner
Thanks for the feedback!

Argyrios Kyrtzidis  writes:
> Thank you for your work on this.
>
> Some high level comments first; the way ModuleDependencyCollector is
> getting hooked up, results in:
>
> - If no module needs building (because module cache has it) no module
>   dependency is getting written out

I realize this, but as far as I can tell there isn't really a practical
way to get all of the module dependencies except for when we actually
create a module. Unless there's a way to extract this information from
an imported ModuleFile that I've missed, I think we need to collect this
information as we parse the AST to build a module in the first place.

If there is a more reliable way to do this, I'm all ears. I should
mention though, for the purposes of getting more useful crash reports
with modules this limitation isn't very important. Notably, it's useful
to collect the .pcm files anyway, and using a fresh cache directory is a
very simple way to do that.

> - It doesn’t hook in the top level module, e.g. if I have "@import
>   Darwin;” then no module dependency is written out even if the module
>   cache is empty.

This seems like a bigger problem, and I don't really understand it.
Where is the module built? I'm pretty convinced that the place I've
hooked into is the only one that creates a CompilerInstance with
BuildingModule set to true...

> Some nitpicks:
>
> @@ -105,6 +105,9 @@ class CompilerInstance : public ModuleLoader {
>/// \brief The ASTReader, if one exists.
>IntrusiveRefCntPtr ModuleManager;
>  
> +  /// \brief The module dependency collector for crashdumps
> +  std::shared_ptr ModuleDepCollector;
> +
>/// \brief The dependency file generator.
>std::unique_ptr TheDependencyFileGenerator;
>
> Is there a policy to avoid IntrusiveRefCntPtr ?

Since we're using C++11 now, I just assumed we'd be migrating to
shared_ptr where appropriate in modern code. I can change it to
IntrusiveRefCntPtr if you like, but I do think shared_ptr is appropriate
here.

> +/// Collects the dependencies for imported modules into a directory.  Users
> +/// should attach to the AST reader whenever a module is loaded.
> +class ModuleDependencyCollector {
> +  StringRef DestDir;
>
> Use std::string here.

Sure.

> +  void reportError() { HasErrors = true; }
>
> Name is a bit misleading, how about "setHasErrors()” ?

Good idea.

> +llvm::error_code ModuleDependencyListener::copyToRoot(StringRef Src) {
> +  using namespace llvm::sys;
> +  SmallString<256> Dest = Collector.getDest();
> +  path::append(Dest, path::relative_path(Src));
>
> Do we need to turn Src into an absolute path first, in case it’s
> relative to the current directory ?

Yes, I think so.

> +  if (llvm::error_code EC = fs::copy_file(Src, Dest.str()))
> +return EC;
>
> Do you have a separate patch that introduces copy_file ?

Oops, forgot to attach that!

Updated patches attached.

>From a151ebfb00b2525b1debc340758d0a6a07b15bb6 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Mon, 12 May 2014 23:16:57 -0700
Subject: [PATCH 1/2] Frontend: Add a CC1 flag to dump module dependencies to a
 directory

This adds the -module-dependency-dir to clang -cc1, which specifies a
directory to copy all of a module's dependencies into in a form
suitable to be used as a VFS. This is useful for crashdumps that
involve modules, so that the module dependencies will be intact when a
crash report script is used to reproduce a problem on another machine.
---
 include/clang/Driver/Options.td  |  2 +
 include/clang/Frontend/CompilerInstance.h|  7 +++
 include/clang/Frontend/DependencyOutputOptions.h |  5 +-
 include/clang/Frontend/Utils.h   | 19 +++
 lib/Frontend/CMakeLists.txt  |  1 +
 lib/Frontend/CompilerInstance.cpp| 26 ++
 lib/Frontend/CompilerInvocation.cpp  |  2 +
 lib/Frontend/ModuleDependencyCollector.cpp   | 64 
 8 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 lib/Frontend/ModuleDependencyCollector.cpp

diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 85f2e0c..dd8722e 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -342,6 +342,8 @@ def dependency_file : Separate<["-"], "dependency-file">, Flags<[CC1Option]>,
   HelpText<"Filename (or -) to write dependency output to">;
 def dependency_dot : Separate<["-"], "dependency-dot">, Flags<[CC1Option]>,
   HelpText<"Filename to write DOT-formatted header dependencies to">;
+def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
+  Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">;
 def dumpmachine : Flag<["-"], "dumpmachine">;
 def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
 def dumpversion : Flag<["-"], "dumpversion">;
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index b144069.

Re: [PATCH] Fix/Improve SourceRange of defaulted destructors

2014-06-18 Thread Richard Smith

Comment at: lib/Sema/SemaDeclCXX.cpp:8883
@@ -8882,3 +8882,3 @@
 
-  SourceLocation Loc = Destructor->getLocation();
+  SourceLocation Loc = Destructor->getLocEnd();
   Destructor->setBody(new (Context) CompoundStmt(Loc));

I think this is a reasonable approach. Do the other `DefineImplicit*` members 
also need this fix?

http://reviews.llvm.org/D4175



___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


Re: [PATCH] Move the calling of emitTargetMD() later.

2014-06-18 Thread robert lytton
use 'auto' in for-loops

http://reviews.llvm.org/D4176

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/xcore-stringtype.c
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -364,6 +364,8 @@
 DebugInfo->finalize();
 
   EmitVersionIdentMetadata();
+
+  EmitTargetMetadata();
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
@@ -1505,8 +1507,6 @@
 }
   }
 
-  getTargetCodeGenInfo().emitTargetMD(D, F, *this);
-
   // Make sure the result is of the requested type.
   if (!IsIncompleteFunction) {
 assert(F->getType()->getElementType() == Ty);
@@ -1656,8 +1656,6 @@
   if (AddrSpace != Ty->getAddressSpace())
 return llvm::ConstantExpr::getAddrSpaceCast(GV, Ty);
 
-  getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
-
   return GV;
 }
 
@@ -3230,8 +3228,7 @@
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
   // StaticLocalDeclMap
-  for (llvm::DenseMap::iterator
- I = MangledDeclNames.begin(), E = MangledDeclNames.end();
+  for (auto I = MangledDeclNames.begin(), E = MangledDeclNames.end();
I != E; ++I) {
 llvm::GlobalValue *Addr = getModule().getNamedValue(I->second);
 EmitGlobalDeclMetadata(*this, GlobalMetadata, I->first, Addr);
@@ -3250,8 +3247,7 @@
 
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
-  for (llvm::DenseMap::iterator
- I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) {
+  for (auto I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) {
 const Decl *D = I->first;
 llvm::Value *Addr = I->second;
 
@@ -3277,6 +3273,15 @@
   IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode));
 }
 
+void CodeGenModule::EmitTargetMetadata() {
+  for (auto I = MangledDeclNames.begin(), E = MangledDeclNames.end();
+   I != E; ++I) {
+const Decl *D = I->first.getDecl()->getMostRecentDecl();
+llvm::GlobalValue *GV = GetGlobalValue(I->second);
+getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
+  }
+}
+
 void CodeGenModule::EmitCoverageFile() {
   if (!getCodeGenOpts().CoverageFile.empty()) {
 if (llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu")) {
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -326,7 +326,7 @@
   CtorList GlobalDtors;
 
   /// A map of canonical GlobalDecls to their mangled names.
-  llvm::DenseMap MangledDeclNames;
+  llvm::MapVector MangledDeclNames;
   llvm::StringMap Manglings;
 
   /// Global annotations.
@@ -1119,6 +1119,9 @@
   /// \brief Emit the Clang version as llvm.ident metadata.
   void EmitVersionIdentMetadata();
 
+  /// Emits target specific Metadata for global declarations.
+  void EmitTargetMetadata();
+
   /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
   /// .gcda files in a way that persists in .bc files.
   void EmitCoverageFile();
Index: test/CodeGen/xcore-stringtype.c
===
--- test/CodeGen/xcore-stringtype.c
+++ test/CodeGen/xcore-stringtype.c
@@ -9,13 +9,13 @@
 // Please see 'Tools Development Guide' section 2.16.2 for format details:
 // 
 
-// CHECK: !xcore.typestrings = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10,
-// CHECK: !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23,
-// CHECK: !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34}
+// CHECK: !xcore.typestrings = !{!1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11,
+// CHECK: !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25,
+// CHECK: !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38}
 
 
 // test BuiltinType
-// CHECK: !0 = metadata !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
+// CHECK: !1 = metadata !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
 // CHECK:  i32, i32, i32, i64, i64, i64, float, double, double)*
 // CHECK:  @builtinType, metadata !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl,
 // CHECK:  ul,sl,sll,ull,sll,ft,d,ld)"}
@@ -28,14 +28,14 @@
 
 
 // test FunctionType & Qualifiers
-// CHECK: !1 = metadata !{void ()* @gI, metadata !"f{0}()"}
-// CHECK: !2 = metadata !{void (...)* @eI, metadata !"f{0}()"}
-// CHECK: !3 = metadata !{void ()* @gV, metadata !"f{0}(0)"}
-// CHECK: !4 = metadata !{void ()* @eV, metadata !"f{0}(0)"}
-// CHECK: !5 = metadata !{void (i32, ...)* @gVA, metadata !"f{0}(si,va)"}
-// CHECK: !6 = metadata !{void (i32, ...)* @eVA, metadata !"f{0}(si,va)"}
-// CHECK: !7 = metadata !{i32* (i32*)* @gQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
-// CHECK: !8 = metadata !{i32* (i32*)* @eQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !2 = metadata !{void ()* @gI, metadata !"f{0}()"}
+// CHECK: !3 = metadata !{void (...)* @eI, metada

Re: [PATCH] Move the calling of emitTargetMD() later.

2014-06-18 Thread robert lytton
Use 'auto' in the for-loops

http://reviews.llvm.org/D4176

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/xcore-stringtype.c
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -364,6 +364,8 @@
 DebugInfo->finalize();
 
   EmitVersionIdentMetadata();
+
+  EmitTargetMetadata();
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
@@ -1505,8 +1507,6 @@
 }
   }
 
-  getTargetCodeGenInfo().emitTargetMD(D, F, *this);
-
   // Make sure the result is of the requested type.
   if (!IsIncompleteFunction) {
 assert(F->getType()->getElementType() == Ty);
@@ -1656,8 +1656,6 @@
   if (AddrSpace != Ty->getAddressSpace())
 return llvm::ConstantExpr::getAddrSpaceCast(GV, Ty);
 
-  getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
-
   return GV;
 }
 
@@ -3230,7 +3228,7 @@
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
   // StaticLocalDeclMap
-  for (llvm::DenseMap::iterator
+  for (llvm::MapVector::iterator
  I = MangledDeclNames.begin(), E = MangledDeclNames.end();
I != E; ++I) {
 llvm::GlobalValue *Addr = getModule().getNamedValue(I->second);
@@ -3250,8 +3248,7 @@
 
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
-  for (llvm::DenseMap::iterator
- I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) {
+  for (auto I = LocalDeclMap.begin(), E = LocalDeclMap.end(); I != E; ++I) {
 const Decl *D = I->first;
 llvm::Value *Addr = I->second;
 
@@ -3277,6 +3274,15 @@
   IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode));
 }
 
+void CodeGenModule::EmitTargetMetadata() {
+  for (auto I = MangledDeclNames.begin(), E = MangledDeclNames.end();
+   I != E; ++I) {
+const Decl *D = I->first.getDecl()->getMostRecentDecl();
+llvm::GlobalValue *GV = GetGlobalValue(I->second);
+getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
+  }
+}
+
 void CodeGenModule::EmitCoverageFile() {
   if (!getCodeGenOpts().CoverageFile.empty()) {
 if (llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu")) {
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -326,7 +326,7 @@
   CtorList GlobalDtors;
 
   /// A map of canonical GlobalDecls to their mangled names.
-  llvm::DenseMap MangledDeclNames;
+  llvm::MapVector MangledDeclNames;
   llvm::StringMap Manglings;
 
   /// Global annotations.
@@ -1119,6 +1119,9 @@
   /// \brief Emit the Clang version as llvm.ident metadata.
   void EmitVersionIdentMetadata();
 
+  /// Emits target specific Metadata for global declarations.
+  void EmitTargetMetadata();
+
   /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
   /// .gcda files in a way that persists in .bc files.
   void EmitCoverageFile();
Index: test/CodeGen/xcore-stringtype.c
===
--- test/CodeGen/xcore-stringtype.c
+++ test/CodeGen/xcore-stringtype.c
@@ -9,13 +9,13 @@
 // Please see 'Tools Development Guide' section 2.16.2 for format details:
 // 
 
-// CHECK: !xcore.typestrings = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10,
-// CHECK: !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23,
-// CHECK: !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34}
+// CHECK: !xcore.typestrings = !{!1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11,
+// CHECK: !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25,
+// CHECK: !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38}
 
 
 // test BuiltinType
-// CHECK: !0 = metadata !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
+// CHECK: !1 = metadata !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
 // CHECK:  i32, i32, i32, i64, i64, i64, float, double, double)*
 // CHECK:  @builtinType, metadata !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl,
 // CHECK:  ul,sl,sll,ull,sll,ft,d,ld)"}
@@ -28,14 +28,14 @@
 
 
 // test FunctionType & Qualifiers
-// CHECK: !1 = metadata !{void ()* @gI, metadata !"f{0}()"}
-// CHECK: !2 = metadata !{void (...)* @eI, metadata !"f{0}()"}
-// CHECK: !3 = metadata !{void ()* @gV, metadata !"f{0}(0)"}
-// CHECK: !4 = metadata !{void ()* @eV, metadata !"f{0}(0)"}
-// CHECK: !5 = metadata !{void (i32, ...)* @gVA, metadata !"f{0}(si,va)"}
-// CHECK: !6 = metadata !{void (i32, ...)* @eVA, metadata !"f{0}(si,va)"}
-// CHECK: !7 = metadata !{i32* (i32*)* @gQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
-// CHECK: !8 = metadata !{i32* (i32*)* @eQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !2 = metadata !{void ()* @gI, metadata !"f{0}()"}
+// CHECK: !3 = metadata !{void (...)* @eI, metadata !"f{0}()"}
+// CHECK: !4 = metadata !{void ()* @gV, metadata !"f{0}(0)"}
+// CHECK: !5 = metadata 

FW: [PATCH] Fix big-endian NEON intrinsics

2014-06-18 Thread James Molloy
Forwarding to cfe-commits as I accidentally added the wrong mail list.

 

From: James Molloy [mailto:james.mol...@arm.com] 
Sent: 17 June 2014 16:25
To: Tim Northover; llvm-commits
Subject: [PATCH] Fix big-endian NEON intrinsics

 

Hi Tim,

 

This is the final big-endian patch in my queue. With it, we pass the emperor
testcases that I've run.

 

The NEON intrinsics in arm_neon.h are designed to work on vectors "as-if"
loaded by (V)LDR. We load vectors "as-if" (V)LD1, so the intrinsics are
currently incorrect.

 

This patch adds big-endian versions of the intrinsics that does the "obvious
but dumb" thing of reversing all vector inputs and all vector outputs. This
will produce extra REVs, but we trust the optimizer to remove them.

 

Could you please review? There's a documentation patch for BigEndianNeon.rst
on the way too.

 

Cheers,

 

James


0001-ARM-BE-Generate-correct-NEON-intrinsics-for-big-endi.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


r211147 - [OPENMP] Reformatting and code improvement.

2014-06-18 Thread Alexey Bataev
Author: abataev
Date: Wed Jun 18 02:08:49 2014
New Revision: 211147

URL: http://llvm.org/viewvc/llvm-project?rev=211147&view=rev
Log:
[OPENMP] Reformatting and code improvement.

Modified:
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=211147&r1=211146&r2=211147&view=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Wed Jun 18 02:08:49 2014
@@ -22,10 +22,9 @@ using namespace clang;
 
 OpenMPDirectiveKind clang::getOpenMPDirectiveKind(StringRef Str) {
   return llvm::StringSwitch(Str)
-#define OPENMP_DIRECTIVE(Name) \
-   .Case(#Name, OMPD_##Name)
+#define OPENMP_DIRECTIVE(Name) .Case(#Name, OMPD_##Name)
 #include "clang/Basic/OpenMPKinds.def"
-   .Default(OMPD_unknown);
+  .Default(OMPD_unknown);
 }
 
 const char *clang::getOpenMPDirectiveName(OpenMPDirectiveKind Kind) {
@@ -33,8 +32,9 @@ const char *clang::getOpenMPDirectiveNam
   switch (Kind) {
   case OMPD_unknown:
 return "unknown";
-#define OPENMP_DIRECTIVE(Name) \
-  case OMPD_##Name : return #Name;
+#define OPENMP_DIRECTIVE(Name) 
\
+  case OMPD_##Name:
\
+return #Name;
 #include "clang/Basic/OpenMPKinds.def"
 break;
   }
@@ -43,10 +43,9 @@ const char *clang::getOpenMPDirectiveNam
 
 OpenMPClauseKind clang::getOpenMPClauseKind(StringRef Str) {
   return llvm::StringSwitch(Str)
-#define OPENMP_CLAUSE(Name, Class) \
-   .Case(#Name, OMPC_##Name)
+#define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
 #include "clang/Basic/OpenMPKinds.def"
-   .Default(OMPC_unknown);
+  .Default(OMPC_unknown);
 }
 
 const char *clang::getOpenMPClauseName(OpenMPClauseKind Kind) {
@@ -54,8 +53,9 @@ const char *clang::getOpenMPClauseName(O
   switch (Kind) {
   case OMPC_unknown:
 return "unknown";
-#define OPENMP_CLAUSE(Name, Class) \
-  case OMPC_##Name : return #Name;
+#define OPENMP_CLAUSE(Name, Class) 
\
+  case OMPC_##Name:
\
+return #Name;
 #include "clang/Basic/OpenMPKinds.def"
   case OMPC_threadprivate:
 return "threadprivate or thread local";
@@ -68,16 +68,14 @@ unsigned clang::getOpenMPSimpleClauseTyp
   switch (Kind) {
   case OMPC_default:
 return llvm::StringSwitch(Str)
-#define OPENMP_DEFAULT_KIND(Name) \
- .Case(#Name, OMPC_DEFAULT_##Name)
+#define OPENMP_DEFAULT_KIND(Name) .Case(#Name, OMPC_DEFAULT_##Name)
 #include "clang/Basic/OpenMPKinds.def"
- .Default(OMPC_DEFAULT_unknown);
+.Default(OMPC_DEFAULT_unknown);
   case OMPC_proc_bind:
 return llvm::StringSwitch(Str)
-#define OPENMP_PROC_BIND_KIND(Name) \
- .Case(#Name, OMPC_PROC_BIND_##Name)
+#define OPENMP_PROC_BIND_KIND(Name) .Case(#Name, OMPC_PROC_BIND_##Name)
 #include "clang/Basic/OpenMPKinds.def"
- .Default(OMPC_PROC_BIND_unknown);
+.Default(OMPC_PROC_BIND_unknown);
   case OMPC_unknown:
   case OMPC_threadprivate:
   case OMPC_if:
@@ -104,8 +102,9 @@ const char *clang::getOpenMPSimpleClause
 switch (Type) {
 case OMPC_DEFAULT_unknown:
   return "unknown";
-#define OPENMP_DEFAULT_KIND(Name) \
-case OMPC_DEFAULT_##Name : return #Name;
+#define OPENMP_DEFAULT_KIND(Name)  
\
+  case OMPC_DEFAULT_##Name:
\
+return #Name;
 #include "clang/Basic/OpenMPKinds.def"
 }
 llvm_unreachable("Invalid OpenMP 'default' clause type");
@@ -113,8 +112,9 @@ const char *clang::getOpenMPSimpleClause
 switch (Type) {
 case OMPC_PROC_BIND_unknown:
   return "unknown";
-#define OPENMP_PROC_BIND_KIND(Name) \
-case OMPC_PROC_BIND_##Name : return #Name;
+#define OPENMP_PROC_BIND_KIND(Name)
\
+  case OMPC_PROC_BIND_##Name:  
\
+return #Name;
 #include "clang/Basic/OpenMPKinds.def"
 }
 llvm_unreachable("Invalid OpenMP 'proc_bind' clause type");
@@ -144,8 +144,9 @@ bool clang::isAllowedClauseForDirective(
   switch (DKind) {
   case OMPD_parallel:
 switch (CKind) {
-#define OPENMP_PARALLEL_CLAUSE(Name) \
-case OMPC_##Name: return true;
+#define OPENMP_PARALLEL_CLAUSE(Name)   
\
+  case OMPC_##Name:
\
+return true;
 #include "clang/Basic/OpenMPKinds.def"
 default:
   break;