Re: [PATCH] D10305: [Clang Static Analyzer] Bug identification

2015-10-08 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Thank you for the review!

Before committing this I would like to have a policy regarding future changes 
and document it inside the IssueHash header.
My proposed policy is the following:

- Do not change the calculation of issue hash unless we have a very good reason 
to do so.
- Every time the way of calculation changes the name of the hash in the plist 
should be changed (this makes it possible for users to patch clang to generate 
both old and new hash for those who are relying on the old hash).

I have some questions though:

- Should we require the generation of old hashes once a change is introduced, 
or should we expect users who rely on old hash to maintain the old hash 
generation as an out of tree patch?
- The hash calculation WILL change in the near future once we figured out how 
to identify checkers properly (but I think it will not make sense to rename the 
hash for this change). For this reason I think we should mark this feature as 
experimental, until that change is introduced. What is the recommended way, to 
do that? Generating a comment to the plist? Just adding a comment to the 
headers? Only mention it in the commit log?

What do you think?


http://reviews.llvm.org/D10305



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


[PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute, NFC.

2015-10-08 Thread Alexey Bataev via cfe-commits
ABataev created this revision.
ABataev added a reviewer: aaron.ballman.
ABataev added a subscriber: cfe-commits.

Automatically insert line feed after pretty printing of all pragma-like 
attributes.

http://reviews.llvm.org/D13546

Files:
  include/clang/Basic/Attr.td
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1180,6 +1180,7 @@
 if (Variety == "Pragma") {
   OS << " \";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
+  OS << "OS << \"\\n\";";
   OS << "break;\n";
   OS << "  }\n";
   continue;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2048,17 +2048,15 @@
 unsigned SpellingIndex = getSpellingListIndex();
 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
 // "nounroll" is already emitted as the pragma name.
-if (SpellingIndex == Pragma_nounroll) {
-  OS << "\n";
+if (SpellingIndex == Pragma_nounroll)
   return;
-}
 else if (SpellingIndex == Pragma_unroll) {
-  OS << getValueString(Policy) << "\n";
+  OS << getValueString(Policy);
   return;
 }
 
 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
-OS << getOptionName(option) << getValueString(Policy) << "\n";
+OS << getOptionName(option) << getValueString(Policy);
   }
 
   // Return a string containing the loop hint argument including the


Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1180,6 +1180,7 @@
 if (Variety == "Pragma") {
   OS << " \";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
+  OS << "OS << \"\\n\";";
   OS << "break;\n";
   OS << "  }\n";
   continue;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2048,17 +2048,15 @@
 unsigned SpellingIndex = getSpellingListIndex();
 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
 // "nounroll" is already emitted as the pragma name.
-if (SpellingIndex == Pragma_nounroll) {
-  OS << "\n";
+if (SpellingIndex == Pragma_nounroll)
   return;
-}
 else if (SpellingIndex == Pragma_unroll) {
-  OS << getValueString(Policy) << "\n";
+  OS << getValueString(Policy);
   return;
 }
 
 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
-OS << getOptionName(option) << getValueString(Policy) << "\n";
+OS << getOptionName(option) << getValueString(Policy);
   }
 
   // Return a string containing the loop hint argument including the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9888: [OPENMP] Driver support for OpenMP offloading

2015-10-08 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

In http://reviews.llvm.org/D9888#262389, @sfantao wrote:

> [...]
>
> I assume you were trying this using the diff in 
> http://reviews.llvm.org/D12614. There was an inconsistency in the names of 
> the ELF sections and symbols defined by the linker script in these two 
> patches. This is now fixed.
>
> Note that if you are using the libomptarget library from clang-omp, you need 
> to replace in the code `.openmptgt_host_entries` by 
> `.omp_offloading.entries`. I changed the names so that all of them are 
> consistent with what is already in place for other OpenMP directives.
>
> I also changed the files generation so that different files are used even if 
> target and host have the same triple.
>
> Please, let me know if it still does not work for you.


Thanks for your help, a small test program now seems to work!

> [...]

> 

> I didn't implement the triples logic for the nvptx targets yet. I'll port 
> that from clang-omp once we have the basic functionality working upstream.


Ok, I'll wait then. Thanks for your work and finally upstreaming this!
Jonas


http://reviews.llvm.org/D9888



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


r249667 - [Sema] Tweak incomplete enum types on MSVC ABI targets

2015-10-08 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Oct  8 02:45:35 2015
New Revision: 249667

URL: http://llvm.org/viewvc/llvm-project?rev=249667&view=rev
Log:
[Sema] Tweak incomplete enum types on MSVC ABI targets

Enums without an explicit, fixed, underlying type are implicitly given a
fixed 'int' type for ABI compatibility with MSVC.  However, we can
enforce the standard-mandated rules on these types as-if we didn't know
this fact if the tag is not part of a definition.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/volatile-1.c
cfe/trunk/test/Parser/cxx0x-attributes.cpp
cfe/trunk/test/Sema/cast-incomplete.c
cfe/trunk/test/Sema/decl-in-prototype.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=249667&r1=249666&r2=249667&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct  8 02:45:35 2015
@@ -11769,8 +11769,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
 EnumUnderlying = Context.IntTy.getTypePtr();
 
 } else if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-  // Microsoft enums are always of int type.
-  EnumUnderlying = Context.IntTy.getTypePtr();
+  if (getLangOpts().MSVCCompat || TUK == TUK_Definition) {
+// Microsoft enums are always of int type.
+EnumUnderlying = Context.IntTy.getTypePtr();
+  }
 }
   }
 

Modified: cfe/trunk/test/CodeGen/volatile-1.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/volatile-1.c?rev=249667&r1=249666&r2=249667&view=diff
==
--- cfe/trunk/test/CodeGen/volatile-1.c (original)
+++ cfe/trunk/test/CodeGen/volatile-1.c Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -Wno-return-type 
-Wno-unused-value -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-return-type -Wno-unused-value -emit-llvm %s -o - | 
FileCheck %s
 
 // CHECK: @i = common global [[INT:i[0-9]+]] 0
 volatile int i, j, k;

Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=249667&r1=249666&r2=249667&view=diff
==
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions 
-fsyntax-only -verify -std=c++11 -Wc++14-compat %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify 
-std=c++11 -Wc++14-compat %s
 
 // Need std::initializer_list
 namespace std {

Modified: cfe/trunk/test/Sema/cast-incomplete.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/cast-incomplete.c?rev=249667&r1=249666&r2=249667&view=diff
==
--- cfe/trunk/test/Sema/cast-incomplete.c (original)
+++ cfe/trunk/test/Sema/cast-incomplete.c Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -verify
 // PR5692
 
 enum x;// expected-note   {{forward declaration}}

Modified: cfe/trunk/test/Sema/decl-in-prototype.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/decl-in-prototype.c?rev=249667&r1=249666&r2=249667&view=diff
==
--- cfe/trunk/test/Sema/decl-in-prototype.c (original)
+++ cfe/trunk/test/Sema/decl-in-prototype.c Thu Oct  8 02:45:35 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -fsyntax-only -verify %s
 
 const int AA = 5;
 


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


Re: [PATCH] D13482: Revised Initial patch for PS4 toolchain

2015-10-08 Thread Katya Romanova via cfe-commits
kromanova updated this revision to Diff 36829.
kromanova added a comment.

Few more changes:

(1) There was a bug, where the PS4 driver didn't add input filename in the call 
to external assembler. 
Filipe fixed this problem in Tools.cpp

(2) A new testcase no-integrated-as.s was added for testing the problem 
described in (1).

(3) A comment is added in ToolChains.cpp to emphasize that the waning about 
missing PS4 SDK headers and libs is ignored by default.


Repository:
  rL LLVM

http://reviews.llvm.org/D13482

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/Inputs/scei-ps4_tree/target/include/.keep
  test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep
  test/Driver/debug-options.c
  test/Driver/no-integrated-as.s
  test/Driver/ps4-header-search.c
  test/Driver/ps4-linker-non-win.c
  test/Driver/ps4-linker-win.c
  test/Driver/ps4-pic.c
  test/Driver/ps4-sdk-root.c
  test/Driver/stack-protector.c

Index: test/Driver/stack-protector.c
===
--- test/Driver/stack-protector.c
+++ test/Driver/stack-protector.c
@@ -23,3 +23,12 @@
 // RUN: %clang -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SSP-ALL
 // SSP-ALL: "-stack-protector" "3"
 // SSP-ALL-NOT: "-stack-protector-buffer-size" 
+
+// RUN: %clang -target x86_64-scei-ps4 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4
+// RUN: %clang -target x86_64-scei-ps4 -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4
+// SSP-PS4: "-stack-protector" "2"
+// SSP-PS4-NOT: "-stack-protector-buffer-size"
+
+// RUN: %clang -target x86_64-scei-ps4 -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4-BUF
+// SSP-PS4-BUF: "-stack-protector" "2"
+// SSP-PS4-BUF: "-stack-protector-buffer-size" "16"
Index: test/Driver/ps4-sdk-root.c
===
--- test/Driver/ps4-sdk-root.c
+++ test/Driver/ps4-sdk-root.c
@@ -0,0 +1,48 @@
+// REQUIRES: x86-registered-target
+
+// Check that ps4-clang doesn't report a warning message when locating
+// system header files (either by looking at the value of SCE_PS4_SDK_DIR
+// or relative to the location of the compiler driver), if "-nostdinc",
+// "--sysroot" or "-isysroot" option is specified on the command line.
+// Otherwise, check that ps4-clang reports a warning.
+
+// Check that clang doesn't report a warning message when locating
+// system libraries (either by looking at the value of SCE_PS4_SDK_DIR
+// or relative to the location of the compiler driver), if "-c", "-S", "-E",
+// "--sysroot", "-nostdlib" or "-nodefaultlibs" option is specified on
+// the command line.
+// Otherwise, check that ps4-clang reports a warning.
+
+// setting up SCE_PS4_SDK_DIR to existing location, which is not a PS4 SDK.
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -

r249670 - Update a few more tests in response to the MS ABI enum semantics

2015-10-08 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Oct  8 03:28:09 2015
New Revision: 249670

URL: http://llvm.org/viewvc/llvm-project?rev=249670&view=rev
Log:
Update a few more tests in response to the MS ABI enum semantics

Our self hosting buildbots found a few more tests which weren't updated
to reflect that the enum semantics are part of the Microsoft ABI.

Modified:
cfe/trunk/test/Sema/fn-ptr-as-fn-prototype.c
cfe/trunk/test/Sema/function-redecl.c
cfe/trunk/test/Sema/inline.c
cfe/trunk/test/Sema/short-enums.c
cfe/trunk/test/SemaCXX/ast-print.cpp
cfe/trunk/test/SemaCXX/conversion-function.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp
cfe/trunk/test/SemaCXX/underlying_type.cpp
cfe/trunk/test/SemaCXX/warn-sign-conversion.cpp
cfe/trunk/test/SemaObjC/blocks.m
cfe/trunk/test/SemaObjC/default-synthesize-1.m
cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp

Modified: cfe/trunk/test/Sema/fn-ptr-as-fn-prototype.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/fn-ptr-as-fn-prototype.c?rev=249670&r1=249669&r2=249670&view=diff
==
--- cfe/trunk/test/Sema/fn-ptr-as-fn-prototype.c (original)
+++ cfe/trunk/test/Sema/fn-ptr-as-fn-prototype.c Thu Oct  8 03:28:09 2015
@@ -7,7 +7,7 @@
 
 // CHECK: typedef void (*g)();
 typedef void (*g) ();
-// CHECK: enum {
+// CHECK: enum
 enum {
   k = -1
 };

Modified: cfe/trunk/test/Sema/function-redecl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function-redecl.c?rev=249670&r1=249669&r2=249670&view=diff
==
--- cfe/trunk/test/Sema/function-redecl.c (original)
+++ cfe/trunk/test/Sema/function-redecl.c Thu Oct  8 03:28:09 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
 
 // PR3588
 void g0(int, int);

Modified: cfe/trunk/test/Sema/inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/inline.c?rev=249670&r1=249669&r2=249670&view=diff
==
--- cfe/trunk/test/Sema/inline.c (original)
+++ cfe/trunk/test/Sema/inline.c Thu Oct  8 03:28:09 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
 
 #if defined(INCLUDE)
 // ---

Modified: cfe/trunk/test/Sema/short-enums.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/short-enums.c?rev=249670&r1=249669&r2=249670&view=diff
==
--- cfe/trunk/test/Sema/short-enums.c (original)
+++ cfe/trunk/test/Sema/short-enums.c Thu Oct  8 03:28:09 2015
@@ -1,5 +1,5 @@
 // RUN: not %clang_cc1 -fsyntax-only %s -verify
-// RUN: %clang_cc1 -fshort-enums -fsyntax-only %s -verify
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fshort-enums -fsyntax-only %s 
-verify
 // expected-no-diagnostics
 
 enum x { A };

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=249670&r1=249669&r2=249670&view=diff
==
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Thu Oct  8 03:28:09 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ast-print %s -std=gnu++11 | FileCheck %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -ast-print %s -std=gnu++11 | 
FileCheck %s
 
 // CHECK: r;
 // CHECK-NEXT: (r->method());
@@ -66,7 +66,7 @@ template  void test7()
 template  void test8(T t) { t.~T(); }
 
 
-// CHECK:  enum E {
+// CHECK:  enum E
 // CHECK-NEXT:  A,
 // CHECK-NEXT:  B,
 // CHECK-NEXT:  C

Modified: cfe/trunk/test/SemaCXX/conversion-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion-function.cpp?rev=249670&r1=249669&r2=249670&view=diff
==
--- cfe/trunk/test/SemaCXX/conversion-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion-function.cpp Thu Oct  8 03:28:09 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wbind-to-temporary-copy -verify %s 
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only 
-Wbind-to-temporary-copy -verify %s 
 class X { 
 public:
   operator bool();

Modified: cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp?rev=249670&r1=249669&r2=249670&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp Thu Oct  8 03:28:09 2015
@@ -859,7 +859,7 @@ namespace ns1 {
 struct X1 {  
   struct 

Re: [PATCH] D10834: Added functions to retrieve information about variable storage in libclang and its python bindings.

2015-10-08 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a subscriber: klimek.
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


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

2015-10-08 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a reviewer: klimek.
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


r249672 - [OPENMP 4.1] Codegen for array sections/subscripts in 'reduction' clause.

2015-10-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  8 04:10:53 2015
New Revision: 249672

URL: http://llvm.org/viewvc/llvm-project?rev=249672&view=rev
Log:
[OPENMP 4.1] Codegen for array sections/subscripts in 'reduction' clause.
OpenMP 4.1 adds support for array sections/subscripts in 'reduction' clause. 
Patch adds codegen for this feature.

Modified:
cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_messages.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h?rev=249672&r1=249671&r2=249672&view=diff
==
--- cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h Thu Oct  8 04:10:53 
2015
@@ -2664,6 +2664,9 @@ RecursiveASTVisitor::VisitOMPRe
   TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
   TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
   TRY_TO(VisitOMPClauseList(C));
+  for (auto *E : C->privates()) {
+TRY_TO(TraverseStmt(E));
+  }
   for (auto *E : C->lhs_exprs()) {
 TRY_TO(TraverseStmt(E));
   }

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=249672&r1=249671&r2=249672&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Oct  8 04:10:53 2015
@@ -1589,16 +1589,29 @@ class OMPReductionClause : public OMPVar
   void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
 
   /// \brief Set list of helper expressions, required for proper codegen of the
+  /// clause. These expressions represent private copy of the reduction
+  /// variable.
+  void setPrivates(ArrayRef Privates);
+
+  /// \brief Get the list of helper privates.
+  MutableArrayRef getPrivates() {
+return MutableArrayRef(varlist_end(), varlist_size());
+  }
+  ArrayRef getPrivates() const {
+return llvm::makeArrayRef(varlist_end(), varlist_size());
+  }
+
+  /// \brief Set list of helper expressions, required for proper codegen of the
   /// clause. These expressions represent LHS expression in the final
   /// reduction expression performed by the reduction clause.
   void setLHSExprs(ArrayRef LHSExprs);
 
   /// \brief Get the list of helper LHS expressions.
   MutableArrayRef getLHSExprs() {
-return MutableArrayRef(varlist_end(), varlist_size());
+return MutableArrayRef(getPrivates().end(), varlist_size());
   }
   ArrayRef getLHSExprs() const {
-return llvm::makeArrayRef(varlist_end(), varlist_size());
+return llvm::makeArrayRef(getPrivates().end(), varlist_size());
   }
 
   /// \brief Set list of helper expressions, required for proper codegen of the
@@ -1640,6 +1653,8 @@ public:
   /// \param VL The variables in the clause.
   /// \param QualifierLoc The nested-name qualifier with location information
   /// \param NameInfo The full name info for reduction identifier.
+  /// \param Privates List of helper expressions for proper generation of
+  /// private copies.
   /// \param LHSExprs List of helper expressions for proper generation of
   /// assignment operation required for copyprivate clause. This list 
represents
   /// LHSs of the reduction expressions.
@@ -1662,8 +1677,9 @@ public:
   Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation 
LParenLoc,
  SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef VL,
  NestedNameSpecifierLoc QualifierLoc,
- const DeclarationNameInfo &NameInfo, ArrayRef LHSExprs,
- ArrayRef RHSExprs, ArrayRef ReductionOps);
+ const DeclarationNameInfo &NameInfo, ArrayRef Privates,
+ ArrayRef LHSExprs, ArrayRef RHSExprs,
+ ArrayRef ReductionOps);
   /// \brief Creates an empty clause with the place for \a N variables.
   ///
   /// \param C AST context.
@@ -1684,6 +1700,12 @@ public:
   typedef llvm::iterator_range
   helper_expr_const_range;
 
+  helper_expr_const_range privates() const {
+return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
+  }
+  helper_expr_range privates() {
+return helper_e

r249674 - [MSVC Compat] Try to treat an implicit, fixed enum as an unfixed enum

2015-10-08 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Oct  8 05:04:46 2015
New Revision: 249674

URL: http://llvm.org/viewvc/llvm-project?rev=249674&view=rev
Log:
[MSVC Compat] Try to treat an implicit, fixed enum as an unfixed enum

consider the following:
enum E *p;
enum E { e };

The above snippet is not ANSI C because 'enum E' has not bee defined
when we are processing the declaration of 'p'; however, it is a popular
extension to make the above work.  This would fail using the Microsoft
enum semantics because the definition of 'E' would implicitly have a
fixed underlying type of 'int' which would trigger diagnostic messages
about a mismatch between the declaration and the definition.

Instead, treat fixed underlying types as not fixed for the purposes of
the diagnostic.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/Sema/bitfield.c
cfe/trunk/test/Sema/decl-in-prototype.c
cfe/trunk/test/SemaObjC/default-synthesize-1.m
cfe/trunk/test/SemaTemplate/instantiate-local-class.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=249674&r1=249673&r2=249674&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct  8 05:04:46 2015
@@ -1984,7 +1984,9 @@ public:
   Expr *val);
   bool CheckEnumUnderlyingType(TypeSourceInfo *TI);
   bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
-  QualType EnumUnderlyingTy, const EnumDecl *Prev);
+  QualType EnumUnderlyingTy,
+  bool EnumUnderlyingIsImplicit,
+  const EnumDecl *Prev);
 
   /// Determine whether the body of an anonymous enumeration should be skipped.
   /// \param II The name of the first enumerator.

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=249674&r1=249673&r2=249674&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct  8 05:04:46 2015
@@ -11454,9 +11454,9 @@ bool Sema::CheckEnumUnderlyingType(TypeS
 
 /// Check whether this is a valid redeclaration of a previous enumeration.
 /// \return true if the redeclaration was invalid.
-bool Sema::CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
-  QualType EnumUnderlyingTy,
-  const EnumDecl *Prev) {
+bool Sema::CheckEnumRedeclaration(
+SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy,
+bool EnumUnderlyingIsImplicit, const EnumDecl *Prev) {
   bool IsFixed = !EnumUnderlyingTy.isNull();
 
   if (IsScoped != Prev->isScoped()) {
@@ -11478,6 +11478,10 @@ bool Sema::CheckEnumRedeclaration(Source
   << Prev->getIntegerTypeRange();
   return true;
 }
+  } else if (IsFixed && !Prev->isFixed() && EnumUnderlyingIsImplicit) {
+;
+  } else if (!IsFixed && Prev->isFixed() && !Prev->getIntegerTypeSourceInfo()) 
{
+;
   } else if (IsFixed != Prev->isFixed()) {
 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
   << Prev->isFixed();
@@ -11747,6 +11751,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   // this early, because it's needed to detect if this is an incompatible
   // redeclaration.
   llvm::PointerUnion EnumUnderlying;
+  bool EnumUnderlyingIsImplicit = false;
 
   if (Kind == TTK_Enum) {
 if (UnderlyingType.isInvalid() || (!UnderlyingType.get() && ScopedEnum))
@@ -11772,6 +11777,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   if (getLangOpts().MSVCCompat || TUK == TUK_Definition) {
 // Microsoft enums are always of int type.
 EnumUnderlying = Context.IntTy.getTypePtr();
+EnumUnderlyingIsImplicit = true;
   }
 }
   }
@@ -12119,7 +12125,8 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   // returning the previous declaration, unless this is a definition,
   // in which case we want the caller to bail out.
   if (CheckEnumRedeclaration(NameLoc.isValid() ? NameLoc : KWLoc,
- ScopedEnum, EnumUnderlyingTy, PrevEnum))
+ ScopedEnum, EnumUnderlyingTy,
+ EnumUnderlyingIsImplicit, PrevEnum))
 return TUK == TUK_Declaration ? PrevTagDecl : nullptr;
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=249674&r1=249673&r2=249674&view=diff
==
--- cfe/trunk/lib/Sema/SemaTe

Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-08 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Please always add cfe-commits as "subscriber" so that the email also goes to 
the list.


Repository:
  rL LLVM

http://reviews.llvm.org/D13549



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


r249676 - [Driver] Use Twine instead of itostr. NFC.

2015-10-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct  8 05:31:17 2015
New Revision: 249676

URL: http://llvm.org/viewvc/llvm-project?rev=249676&view=rev
Log:
[Driver] Use Twine instead of itostr. NFC.

No need to construct temporary std::strings here.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=249676&r1=249675&r2=249676&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct  8 05:31:17 2015
@@ -2353,7 +2353,7 @@ static void RenderDebugEnablingArgs(cons
   }
   if (DwarfVersion > 0)
 CmdArgs.push_back(
-Args.MakeArgString("-dwarf-version=" + llvm::itostr(DwarfVersion)));
+Args.MakeArgString("-dwarf-version=" + Twine(DwarfVersion)));
 }
 
 static void CollectArgsForIntegratedAssembler(Compilation &C,


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


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

2015-10-08 Thread Sean Eveson via cfe-commits
seaneveson updated this revision to Diff 36845.
seaneveson added a comment.

Move PR21606 test into const-method-call.cpp.
Added test for const calls on member objects.
Added tests for inherited const methods.
Changed TK_PreserveContents to be set for the base region. This is so memory is 
still preserved when 'this' is a member of another object.
Added code to get the instance's class, rather than the method's class. This 
solves issues where the method's class has no mutable members, but the class 
which inherits the method does.


http://reviews.llvm.org/D13099

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/const-method-call.cpp

Index: test/Analysis/const-method-call.cpp
===
--- test/Analysis/const-method-call.cpp
+++ test/Analysis/const-method-call.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(bool);
+
+struct A {
+  int x;
+  void foo() const;
+  void bar();
+};
+
+struct B {
+  mutable int mut;
+  void foo() const;
+};
+
+struct C {
+  int *p;
+  void foo() const;
+};
+
+struct MutBase {
+  mutable int b_mut;
+};
+
+struct MutDerived : MutBase {
+  void foo() const;
+};
+
+struct PBase {
+  int *p;
+};
+
+struct PDerived : PBase {
+  void foo() const;
+};
+
+struct Inner {
+  int x;
+  int *p;
+  void bar() const;
+};
+
+struct Outer {
+  int x;
+  Inner in;
+  void foo() const;
+};
+
+void checkThatConstMethodWithoutDefinitionDoesNotInvalidateObject() {
+  A t;
+  t.x = 3;
+  t.foo();
+  clang_analyzer_eval(t.x == 3); // expected-warning{{TRUE}}
+  // Test non-const does invalidate
+  t.bar();
+  clang_analyzer_eval(t.x); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatConstMethodDoesInvalidateMutableFields() {
+  B t;
+  t.mut = 4;
+  t.foo();
+  clang_analyzer_eval(t.mut); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatConstMethodDoesInvalidatePointedAtMemory() {
+  int x = 1;
+  C t;
+  t.p = &x;
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.p == &x); // expected-warning{{TRUE}}
+}
+
+void checkThatConstMethodDoesInvalidateInheritedMutableFields() {
+  MutDerived t;
+  t.b_mut = 4;
+  t.foo();
+  clang_analyzer_eval(t.b_mut); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatConstMethodDoesInvalidateInheritedPointedAtMemory() {
+  int x = 1;
+  PDerived t;
+  t.p = &x;
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.p == &x); // expected-warning{{TRUE}}
+}
+
+void checkThatConstMethodDoesInvalidateContainedPointedAtMemory() {
+  int x = 1;
+  Outer t;
+  t.x = 2;
+  t.in.p = &x;
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.x == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.p == &x); // expected-warning{{TRUE}}
+}
+
+void checkThatContainedConstMethodDoesNotInvalidateObjects() {
+  Outer t;
+  t.x = 1;
+  t.in.x = 2;
+  t.in.bar();
+  clang_analyzer_eval(t.x == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.x == 2); // expected-warning{{TRUE}}
+}
+
+// --- Versions of the above tests where the const method is inherited --- //
+
+struct B1 {
+  void foo() const;
+};
+
+struct D1 : public B1 {
+  int x;
+};
+
+struct D2 : public B1 {
+  mutable int mut;
+};
+
+struct D3 : public B1 {
+  int *p;
+};
+
+struct DInner : public B1 {
+  int x;
+  int *p;
+};
+
+struct DOuter : public B1 {
+  int x;
+  DInner in;
+};
+
+void checkThatInheritedConstMethodDoesNotInvalidateObject() {
+  D1 t;
+  t.x = 1;
+  t.foo();
+  clang_analyzer_eval(t.x == 1); // expected-warning{{TRUE}}
+}
+
+void checkThatInheritedConstMethodDoesInvalidateMutableFields() {
+  D2 t;
+  t.mut = 1;
+  t.foo();
+  clang_analyzer_eval(t.mut); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatInheritedConstMethodDoesInvalidatePointedAtMemory() {
+  int x = 1;
+  D3 t;
+  t.p = &x;
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.p == &x); // expected-warning{{TRUE}}
+}
+
+void checkThatInheritedConstMethodDoesInvalidateContainedPointedAtMemory() {
+  int x = 1;
+  DOuter t;
+  t.x = 2;
+  t.in.x = 3;
+  t.in.p = &x;
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.x == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.p == &x); // expected-warning{{TRUE}}
+}
+
+void checkThatInheritedContainedConstMethodDoesNotInvalidateObjects() {
+  DOuter t;
+  t.x = 1;
+  t.in.x = 2;
+  t.in.foo();
+  clang_analyzer_eval(t.x == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.x == 2); // expected-warning{{TRUE}}
+}
+
+// --- PR21606 --- //
+
+struct s1 {
+void g(const int *i) const;
+};
+
+struct s2 {
+void f(int *i) {
+m_i = i;
+m_s.g(m_i);
+ 

Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread don hinton via cfe-commits
hintonda added a comment.

Installed cmake 2.8.12 and was able to reproduce error.

I'll look into it, but I'm tempted to only support newer versions of cmake, and 
let older versions maintain current behavior.


http://reviews.llvm.org/D13453



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


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

2015-10-08 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D13099#260531, @seaneveson wrote:

> There is an issue where pointers to the object (this) should cause it to be 
> invalidated, but don't since TK_PreserveContents has been set.
>
> For example:
>
>   class B;
>   class A {
> B b;
> const foo();
>   };
>   class B {
> A *ptr_a;
>   }
>  
>   A a;
>   a.b.ptr_a = &a;
>   a.foo();
>
>
> The method foo might modify 'this' via the object b, but 'this' will not be 
> invalidated as foo is const.
>
> Again I'm not sure this is worth checking for, based on the assumption that a 
> reasonable const method won't modify the relevant object. What do people 
> think?


I think, this can happen every time, when tehere is a cycle of pointers. Even 
if you do not deal with this case I think it would be great to have an XFAIL 
test with a fixme that describes this limitation.

In case we would like to fix this issue in the future, I think 
TK_PreserveContents is too weak. It would be great to have more control, when 
to preserve the content. E.g. a trait which describes that, this region can not 
be invalidated by that pointer. It is a good question whether a more precise 
solution can be efficient enough though.


http://reviews.llvm.org/D13099



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


Re: [PATCH] D13383: [clang] Add flag to DeclContext to distinguish between qualified and unqualified name lookups

2015-10-08 Thread Eugene Leviant via cfe-commits
evgeny777 added a comment.

Can someone look at it, please?


http://reviews.llvm.org/D13383



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


Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute, NFC.

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

LGTM, thanks! If you would be so kind as to add a test for #pragma 
init_seg("bss"), that would be great -- it seems its printPrettyPragma never 
put a newline in there for that attribute, and so I would guess there's lacking 
test coverage that this change should fix.

~Aaron


http://reviews.llvm.org/D13546



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-08 Thread Marek Kurdej via cfe-commits
curdeius updated this revision to Diff 36849.
curdeius added a comment.

Escape XML-reserved characters.


http://reviews.llvm.org/D13549

Files:
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
  tools/clang-format/ClangFormat.cpp

Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -201,15 +201,30 @@
 static void outputReplacementXML(StringRef Text) {
   size_t From = 0;
   size_t Index;
-  while ((Index = Text.find_first_of("\n\r", From)) != StringRef::npos) {
+  while ((Index = Text.find_first_of("\n\r<>&\"'", From)) != StringRef::npos) {
 llvm::outs() << Text.substr(From, Index - From);
 switch (Text[Index]) {
 case '\n':
   llvm::outs() << "
";
   break;
 case '\r':
   llvm::outs() << "
";
   break;
+case '<':
+  llvm::outs() << "<";
+  break;
+case '>':
+  llvm::outs() << ">";
+  break;
+case '&':
+  llvm::outs() << "&";
+  break;
+case '\'':
+  llvm::outs() << "'";
+  break;
+case '"':
+  llvm::outs() << """;
+  break;
 default:
   llvm_unreachable("Unexpected character encountered!");
 }
Index: tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
===
--- tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
+++ tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -32,13 +32,16 @@
 [CLSCompliant(false), ComVisible(true)]
 public class OptionPageGrid : DialogPage
 {
-private string style = "File";
+private string assumeFilename = "";
+private string fallbackStyle = "LLVM";
+private bool sortIncludes = false;
+private string style = "file";
 
 [Category("LLVM/Clang")]
 [DisplayName("Style")]
 [Description("Coding style, currently supports:\n" +
- "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla').\n" +
- "  - 'File' to search for a YAML .clang-format or _clang-format\n" +
+ "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" +
+ "  - 'file' to search for a YAML .clang-format or _clang-format\n" +
  "configuration file.\n" +
  "  - A YAML configuration snippet.\n\n" +
  "'File':\n" +
@@ -53,6 +56,38 @@
 get { return style; }
 set { style = value; }
 }
+
+[Category("LLVM/Clang")]
+[DisplayName("Assume Filename")]
+[Description("When reading from stdin, clang-format assumes this " +
+ "filename to look for a style config file (with 'file' style) \n" +
+ "and to determine the language.")]
+public string AssumeFilename
+{
+get { return assumeFilename; }
+set { assumeFilename = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Fallback Style")]
+[Description("The name of the predefined style used as a fallback in case clang-format " +
+ "is invoked with 'file' style, but can not find the configuration file.\n" +
+ "Use 'none' fallback style to skip formatting.")]
+public string FallbackStyle
+{
+get { return fallbackStyle; }
+set { fallbackStyle = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Sort includes")]
+[Description("Sort touched include lines.\n\n" +
+ "See also: http://clang.llvm.org/docs/ClangFormat.html.";)]
+public bool SortIncludes
+{
+get { return sortIncludes; }
+set { sortIncludes = value; }
+}
 }
 
 [PackageRegistration(UseManagedResourcesOnly = true)]
@@ -138,10 +173,17 @@
 // Poor man's escaping - this will not work when quotes are already escaped
 // in the input (but we don't need more).
 string style = GetStyle().Replace("\"", "\\\"");
+string fallbackStyle = GetFallbackStyle().Replace("\"", "\\\"");
 process.StartInfo.Arguments = " -offset " + offset +
 

Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute, NFC.

2015-10-08 Thread Bataev, Alexey via cfe-commits

Ok, will do

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

08.10.2015 16:02, Aaron Ballman пишет:

aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thanks! If you would be so kind as to add a test for #pragma 
init_seg("bss"), that would be great -- it seems its printPrettyPragma never 
put a newline in there for that attribute, and so I would guess there's lacking test 
coverage that this change should fix.

~Aaron


http://reviews.llvm.org/D13546





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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Marshall Clow via cfe-commits
On Wed, Oct 7, 2015 at 2:38 PM, Richard Smith  wrote:

> Marshall: ping, does the below satisfy your concerns about the direction
> here?
>

No, not really, because I'm worried about behavior changes with this
approach.

#include 
   isdigit(c);

will call different code before and after this patch.
Before the patch, it will use the macro version.
After, it will use the built-in function.

However, since other standard libraries use this approach, this is probably
a baseless concern.

Assuming that my concerns are unfounded, the first six patches
(remove-macros, nullptr, ctype, errno and float) look fine to me.

Working on the rest.

-- Marshall



> On Wed, Sep 16, 2015 at 2:04 PM, Richard Smith 
> wrote:
>
>> On Mon, Sep 14, 2015 at 7:07 AM, Marshall Clow 
>> wrote:
>>
>>> mclow.lists added a comment.
>>>
>>> I have two concerns about this patch (w/o commenting on the actual code).
>>>
>>> 1. Until very recently, I was under the impression that C libraries
>>> _either_ defined a macro, or had a function. I was quite surprised to find
>>> that glibc did both.
>>
>>
>> Yes, this is required by the C standard. C11 7.1.4/1 says:
>>
>> "Any function declared in a header may be additionally implemented as a
>> function-like macro defined in the header [...]. Any macro definition of a
>> function can be suppressed locally by enclosing the name of the function in
>> parentheses, because the name is then not followed by the left parenthesis
>> that indicates expansion of a macro function name. For the same syntactic
>> reason, it is permitted to take the address of a library function even if
>> it is also defined as a macro. [Footnote: This means that an implementation
>> shall provide an actual function for each library function, even if it also
>> provides a macro for that function.]"
>>
>> Have you checked other C libraries (Apple, FreeBSD, Android, Windows) to
>>> see if they also define both?
>>
>>
>> No, but libstdc++ does the same #undef thing, so any platform it supports
>> must have a non-broken C standard library.
>>
>>
>>> 2. This adds a lot of header files. Each header file slows down
>>> compilation, and standard library header files get included *a lot*. We may
>>> not be able to avoid this, but we should think about the costs here.
>>
>>
>> I created a .cpp file that includes all of the <*.h> headers and does
>> nothing else (which should maximize the performance difference), and built
>> it with and without this change. I could not measure any difference (the
>> average compile time with this change was slightly lower, but that is
>> almost certainly noise).
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute.

2015-10-08 Thread Alexey Bataev via cfe-commits
ABataev retitled this revision from "[ATTR] Automatic line feed after 
pragma-like attribute, NFC." to "[ATTR] Automatic line feed after pragma-like 
attribute.".
ABataev updated this revision to Diff 36850.
ABataev added a comment.

Printing of pragma-like attributes for declarations did not worked at all. 
Fixed it and added test for printing #pragma init_seg.


http://reviews.llvm.org/D13546

Files:
  include/clang/Basic/Attr.td
  lib/AST/DeclPrinter.cpp
  test/SemaCXX/pragma-init_seg.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -95,7 +95,7 @@
 
 void PrintTemplateParameters(const TemplateParameterList *Params,
  const TemplateArgumentList *Args = nullptr);
-void prettyPrintAttributes(Decl *D);
+void prettyPrintAttributes(Decl *D, bool PrintPragmas = false);
 void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
   };
 }
@@ -194,15 +194,27 @@
   return Out;
 }
 
-void DeclPrinter::prettyPrintAttributes(Decl *D) {
+void DeclPrinter::prettyPrintAttributes(Decl *D, bool PrintPragmas) {
   if (Policy.PolishForDeclaration)
 return;
-  
+
   if (D->hasAttrs()) {
 AttrVec &Attrs = D->getAttrs();
-for (AttrVec::const_iterator i=Attrs.begin(), e=Attrs.end(); i!=e; ++i) {
-  Attr *A = *i;
-  A->printPretty(Out, Policy);
+for (auto *A : Attrs) {
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+if (PrintPragmas) {
+  A->printPretty(Out, Policy);
+  Indent();
+}
+break;
+  default:
+if (!PrintPragmas)
+  A->printPretty(Out, Policy);
+break;
+  }
 }
   }
 }
@@ -408,6 +420,10 @@
 }
 
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
+  if (!D->getDescribedFunctionTemplate() &&
+  !D->isFunctionTemplateSpecialization())
+prettyPrintAttributes(D, /*PrintPragmas=*/true);
+
   CXXConstructorDecl *CDecl = dyn_cast(D);
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
   if (!Policy.SuppressSpecifiers) {
@@ -643,6 +659,7 @@
 }
 
 void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isMutable())
 Out << "mutable ";
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
@@ -672,6 +689,7 @@
 }
 
 void DeclPrinter::VisitVarDecl(VarDecl *D) {
+  prettyPrintAttributes(D, /*PrintPragmas=*/true);
   if (!Policy.SuppressSpecifiers) {
 StorageClass SC = D->getStorageClass();
 if (SC != SC_None)
@@ -779,6 +797,7 @@
 }
 
 void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
   Out << D->getKindName();
@@ -914,11 +933,13 @@
   if (PrintInstantiation) {
 TemplateParameterList *Params = D->getTemplateParameters();
 for (auto *I : D->specializations()) {
+  prettyPrintAttributes(I, /*PrintPragmas=*/true);
   PrintTemplateParameters(Params, I->getTemplateSpecializationArgs());
   Visit(I);
 }
   }
 
+  prettyPrintAttributes(D->getTemplatedDecl(), /*PrintPragmas=*/true);
   return VisitRedeclarableTemplateDecl(D);
 }
 
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1180,6 +1180,7 @@
 if (Variety == "Pragma") {
   OS << " \";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
+  OS << "OS << \"\\n\";";
   OS << "break;\n";
   OS << "  }\n";
   continue;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2048,17 +2048,15 @@
 unsigned SpellingIndex = getSpellingListIndex();
 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
 // "nounroll" is already emitted as the pragma name.
-if (SpellingIndex == Pragma_nounroll) {
-  OS << "\n";
+if (SpellingIndex == Pragma_nounroll)
   return;
-}
 else if (SpellingIndex == Pragma_unroll) {
-  OS << getValueString(Policy) << "\n";
+  OS << getValueString(Policy);
   return;
 }
 
 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
-OS << getOptionName(option) << getValueString(Policy) << "\n";
+OS << getOptionName(option) << getValueString(Policy);
   }
 
   // Return a string containing the loop hint argument including the
Index: test/SemaCXX/pragma-init_seg.cpp
===
--- test/SemaCXX/pragma-init_seg.cpp
+++ test/SemaCXX/pragma-init_seg.cpp
@@ -1

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Aaron Ballman via cfe-commits
(Removing llvm-commits, adding cfe-commits)

On Wed, Oct 7, 2015 at 8:07 PM, Adrian Zgorzalek via llvm-commits
 wrote:
> Hey,
>
> Here is an attempt to fix https://llvm.org/bugs/show_bug.cgi?id=25067.

Thank you for working on this!

>
> Summary:
>
> After introducing no_sanitize, we try to map no_sanitize_* into a
> no_sanitize(“*”), the switch in code, however doesn’t handle cases when
> attribute is surrounded by two underscores on each of the ends. In this
> patch I am trying to utilize existing normalizeAttrName function, by
> exposing it to outside world and using it before feeding input to the
> switch.
>
> Added unit tests for the crashes I encountered and patched.

I am hesitant to expose a normalized attribute name API like that
because very little should ever care about the actual spelling string
of the attribute; instead, it should be looking at the semantic
spelling or the (parsed) attribute kind. However, the no sanitize
attributes are a bit strange in that they don't have different
semantic spellings, but instead use the list of sanitizers, so that
approach won't work.

I think the better way to handle this is to refactor SemaDeclAttr.cpp
to have a helper function named normalizeName() and use it in
handleOwnershipAttr, handleFormatAttr, handleModeAttr, and
handleNoSanitizeSpecificAttr. It can be used for normalizing attribute
names as well as attribute argument names.

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


Fwd: [modules] PR24954

2015-10-08 Thread Vassil Vassilev via cfe-commits

Forwarding to cfe-commits


 Forwarded Message 
Subject:[modules] PR24954
Date:   Thu, 8 Oct 2015 15:53:55 +0200
From:   Vassil Vassilev 
To: 	Richard Smith , cfe-...@cs.uiuc.edu 


CC: Ben Langmuir 



Hi Richard,
  I started working on https://llvm.org/bugs/show_bug.cgi?id=24954

  IIUC r228485 introduces an abstraction to deal with
not-really-anonymous friend decls
(serialization::needsAnonymousDeclarationNumber in ASTCommon.cpp).

  A comment explicitly says:
  "// This doesn't apply to friend tag decls; Sema makes those
available to name
   // lookup in the surrounding context."

  In the bug reproducer, the friend function (wrt __iom_t10) is forward
declared in the same namespace, where Sema makes the friend available
for a name lookup.

  It seems that the friend operator<< in __iom_t10 (sorry about the
names they come from libcxx) doesn't get registered in the ASTWriter's
DeclIDs but it gets registered in outer namespace's lookup table. Thus,
assert is triggered when finalizing module A, since it rebuilds the
lookups of the updated contexts.

  The issue only appears when building module A deserializes/uses module B.

  Currently I was assume that something wrong happens in either
needsAnonymousDeclarationNumber or I hit a predicted issue
ASTWriterDecl.cpp:1602
// FIXME: This is not correct; when we reach an imported declaration we
// won't emit its previous declaration.
(void)Writer.GetDeclRef(D->getPreviousDecl());
(void)Writer.GetDeclRef(MostRecent);

  The issue seems a fairly complex one and I am a bit stuck.

  Any hints are very very welcome ;)
Many thanks,
Vassil





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


Re: [PATCH] D13482: Revised Initial patch for PS4 toolchain

2015-10-08 Thread Filipe Cabecinhas via cfe-commits
filcab accepted this revision.
filcab added a comment.
This revision is now accepted and ready to land.

LGTM. But let's wait for a !Sony dev to say something too.


Repository:
  rL LLVM

http://reviews.llvm.org/D13482



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


Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute.

2015-10-08 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Wow, good catch on the fact that this didn't work at all! Thank you for 
tackling it.



Comment at: lib/AST/DeclPrinter.cpp:197
@@ -196,3 +196,3 @@
 
-void DeclPrinter::prettyPrintAttributes(Decl *D) {
+void DeclPrinter::prettyPrintAttributes(Decl *D, bool PrintPragmas) {
   if (Policy.PolishForDeclaration)

Would it make more sense to add a prettyPrintPragmas(Decl *D) function instead?


Comment at: test/SemaCXX/pragma-init_seg.cpp:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
x86_64-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
x86_64-pc-win32 -ast-print | FileCheck %s
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
i386-apple-darwin13.3.0

I think this should be a new test under Misc\. We have ast-print-pragmas.cpp 
that looks like a good place for it to go.


http://reviews.llvm.org/D13546



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


r249692 - [Myriad]: default the Dwarf version to 2

2015-10-08 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Thu Oct  8 09:18:02 2015
New Revision: 249692

URL: http://llvm.org/viewvc/llvm-project?rev=249692&view=rev
Log:
[Myriad]: default the Dwarf version to 2

Modified:
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=249692&r1=249691&r2=249692&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Oct  8 09:18:02 2015
@@ -981,6 +981,7 @@ public:
   Tool *SelectTool(const JobAction &JA) const override;
   void getCompilerSupportDir(std::string &Dir) const;
   void getBuiltinLibDir(std::string &Dir) const;
+  unsigned GetDefaultDwarfVersion() const override { return 2; }
 
 protected:
   Tool *buildLinker() const override;

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=249692&r1=249691&r2=249692&view=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Thu Oct  8 09:18:02 2015
@@ -57,3 +57,6 @@
 // RUN: %clang -target sparc-myriad -### -nostdlib %s 2>&1 | FileCheck %s 
--check-prefix=NOSTDLIB
 //
 // NOSTDLIB-NOT: "-lc"
+
+// RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck 
-check-prefix=G_SPARC %s
+// G_SPARC: "-debug-info-kind=limited" "-dwarf-version=2"


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


r249693 - [VFS] Use VFS instead of virtual files in PPCallbacks test.

2015-10-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct  8 09:20:14 2015
New Revision: 249693

URL: http://llvm.org/viewvc/llvm-project?rev=249693&view=rev
Log:
[VFS] Use VFS instead of virtual files in PPCallbacks test.

Modified:
cfe/trunk/unittests/Lex/PPCallbacksTest.cpp

Modified: cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPCallbacksTest.cpp?rev=249693&r1=249692&r2=249693&view=diff
==
--- cfe/trunk/unittests/Lex/PPCallbacksTest.cpp (original)
+++ cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Thu Oct  8 09:20:14 2015
@@ -110,15 +110,16 @@ public:
 class PPCallbacksTest : public ::testing::Test {
 protected:
   PPCallbacksTest()
-  : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
-DiagOpts(new DiagnosticOptions()),
+  : InMemoryFileSystem(new vfs::InMemoryFileSystem),
+FileMgr(FileSystemOptions(), InMemoryFileSystem),
+DiagID(new DiagnosticIDs()), DiagOpts(new DiagnosticOptions()),
 Diags(DiagID, DiagOpts.get(), new IgnoringDiagConsumer()),
 SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions()) {
 TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
   }
 
-  FileSystemOptions FileMgrOpts;
+  IntrusiveRefCntPtr InMemoryFileSystem;
   FileManager FileMgr;
   IntrusiveRefCntPtr DiagID;
   IntrusiveRefCntPtr DiagOpts;
@@ -133,7 +134,8 @@ protected:
   void AddFakeHeader(HeaderSearch& HeaderInfo, const char* HeaderPath, 
 bool IsSystemHeader) {
   // Tell FileMgr about header.
-  FileMgr.getVirtualFile(HeaderPath, 0, 0);
+  InMemoryFileSystem->addFile(HeaderPath, 0,
+  llvm::MemoryBuffer::getMemBuffer("\n"));
 
   // Add header's parent path to search path.
   StringRef SearchPath = llvm::sys::path::parent_path(HeaderPath);


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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Marshall Clow via cfe-commits
On Tue, Oct 6, 2015 at 3:36 PM, Richard Smith  wrote:

> Split  out of . This is a big change, but the same pattern
> as the prior ones.
>
> In this patch, you replicate the #ifdef XXX, __libcpp_XXX, #undef XXX
dance for all the isXXX functions. Is that because they're not required to
be actual functions in a C library?

Other than that Q, LGTM. Like the extended tests.

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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Marshall Clow via cfe-commits
On Tue, Oct 6, 2015 at 3:42 PM, Richard Smith  wrote:

> , an easy one. We guarantee a setjmp macro exists even if this
> header is somehow included from C (the C standard allows that, so it's not
> worth checking for __cplusplus).
>
> This looks fine to me.

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


[PATCH] D13554: [X86] Enable soft float ABI for x86

2015-10-08 Thread Michael Kuperstein via cfe-commits
mkuper created this revision.
mkuper added reviewers: rafael, rnk.
mkuper added a subscriber: cfe-commits.

The Intel MCU psABI is a new soft-float ABI, based on the IA32 psABI. 
The document describing the ABI can be found here: 
https://github.com/hjl-tools/x86-psABI/wiki/iamcu-psABI-0.7.pdf 

Perhaps the biggest difference between the IA32 and MCU ABIs is that the MCU 
ABI is soft-float. 
This patch makes the x86-32 ABI code respect "-mfloat-abi soft" and generate 
float inreg arguments.

This is the first patch in a series - there will be separate patches to add the 
"-miamcu" driver option, as well as more ABI adjustments to actually make it 
work.

(I'll clean up the one-letter variable names in a separate commit.)

http://reviews.llvm.org/D13554

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/x86-soft-float.c

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -798,6 +798,7 @@
   bool IsDarwinVectorABI;
   bool IsSmallStructInRegABI;
   bool IsWin32StructABI;
+  bool IsSoftFloatABI;
   unsigned DefaultNumRegisterParameters;
 
   static bool isRegisterSize(unsigned Size) {
@@ -846,16 +847,17 @@
 QualType Ty) const override;
 
   X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool d, bool p, bool w,
-unsigned r)
+unsigned r, bool s)
 : ABIInfo(CGT), IsDarwinVectorABI(d), IsSmallStructInRegABI(p),
-  IsWin32StructABI(w), DefaultNumRegisterParameters(r) {}
+  IsWin32StructABI(w), DefaultNumRegisterParameters(r),
+  IsSoftFloatABI(s) {}
 };
 
 class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
-  bool d, bool p, bool w, unsigned r)
-:TargetCodeGenInfo(new X86_32ABIInfo(CGT, d, p, w, r)) {}
+  bool d, bool p, bool w, unsigned r, bool s)
+:TargetCodeGenInfo(new X86_32ABIInfo(CGT, d, p, w, r, s)) {}
 
   static bool isStructReturnInRegABI(
   const llvm::Triple &Triple, const CodeGenOptions &Opts);
@@ -1206,10 +1208,12 @@
 bool X86_32ABIInfo::shouldUseInReg(QualType Ty, CCState &State,
bool &NeedsPadding) const {
   NeedsPadding = false;
-  Class C = classify(Ty);
-  if (C == Float)
-return false;
-
+  if (!IsSoftFloatABI) {
+Class C = classify(Ty);  
+if (C == Float)
+  return false;
+  }
+  
   unsigned Size = getContext().getTypeSize(Ty);
   unsigned SizeInRegs = (Size + 31) / 32;
 
@@ -1877,7 +1881,7 @@
 public:
   WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
 bool d, bool p, bool w, unsigned RegParms)
-: X86_32TargetCodeGenInfo(CGT, d, p, w, RegParms) {}
+: X86_32TargetCodeGenInfo(CGT, d, p, w, RegParms, false) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override;
@@ -7389,7 +7393,8 @@
 } else {
   return *(TheTargetCodeGenInfo = new X86_32TargetCodeGenInfo(
Types, IsDarwinVectorABI, IsSmallStructInRegABI,
-   IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters));
+   IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters,
+   CodeGenOpts.FloatABI == "soft"));
 }
   }
 
Index: test/CodeGen/x86-soft-float.c
===
--- test/CodeGen/x86-soft-float.c
+++ test/CodeGen/x86-soft-float.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -emit-llvm %s -o - 
| FileCheck %s -check-prefix=HARD
+// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -mfloat-abi soft 
-emit-llvm %s -o - | FileCheck %s -check-prefix=SOFT
+
+// HARD: define void @f1(float %a)
+// SOFT: define void @f1(float inreg %a)
+void f1(float a) {}


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -798,6 +798,7 @@
   bool IsDarwinVectorABI;
   bool IsSmallStructInRegABI;
   bool IsWin32StructABI;
+  bool IsSoftFloatABI;
   unsigned DefaultNumRegisterParameters;
 
   static bool isRegisterSize(unsigned Size) {
@@ -846,16 +847,17 @@
 QualType Ty) const override;
 
   X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool d, bool p, bool w,
-unsigned r)
+unsigned r, bool s)
 : ABIInfo(CGT), IsDarwinVectorABI(d), IsSmallStructInRegABI(p),
-  IsWin32StructABI(w), DefaultNumRegisterParameters(r) {}
+  IsWin32StructABI(w), DefaultNumRegisterParameters(r),
+  IsSoftFloatABI(s) {}
 };
 
 class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
-  bool d, bool p, bool w, unsigned r)
-:TargetCodeGenInfo(new X86_32ABIInfo(CGT, d, p, w, r)) {}
+  bool d, bool p, bool w, unsigned r, bool s)
+

Re: r249692 - [Myriad]: default the Dwarf version to 2

2015-10-08 Thread David Blaikie via cfe-commits
On Oct 8, 2015 7:19 AM, "Douglas Katzman via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>
> Author: dougk
> Date: Thu Oct  8 09:18:02 2015
> New Revision: 249692
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249692&view=rev
> Log:
> [Myriad]: default the Dwarf version to 2

Just out of curiosity, what are the particular platform/tool issues that
lead to this limitation?

>
> Modified:
> cfe/trunk/lib/Driver/ToolChains.h
> cfe/trunk/test/Driver/myriad-toolchain.c
>
> Modified: cfe/trunk/lib/Driver/ToolChains.h
> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=249692&r1=249691&r2=249692&view=diff
>
==
> --- cfe/trunk/lib/Driver/ToolChains.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains.h Thu Oct  8 09:18:02 2015
> @@ -981,6 +981,7 @@ public:
>Tool *SelectTool(const JobAction &JA) const override;
>void getCompilerSupportDir(std::string &Dir) const;
>void getBuiltinLibDir(std::string &Dir) const;
> +  unsigned GetDefaultDwarfVersion() const override { return 2; }
>
>  protected:
>Tool *buildLinker() const override;
>
> Modified: cfe/trunk/test/Driver/myriad-toolchain.c
> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=249692&r1=249691&r2=249692&view=diff
>
==
> --- cfe/trunk/test/Driver/myriad-toolchain.c (original)
> +++ cfe/trunk/test/Driver/myriad-toolchain.c Thu Oct  8 09:18:02 2015
> @@ -57,3 +57,6 @@
>  // RUN: %clang -target sparc-myriad -### -nostdlib %s 2>&1 | FileCheck
%s --check-prefix=NOSTDLIB
>  //
>  // NOSTDLIB-NOT: "-lc"
> +
> +// RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck
-check-prefix=G_SPARC %s
> +// G_SPARC: "-debug-info-kind=limited" "-dwarf-version=2"
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2015-10-08 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In http://reviews.llvm.org/D12901#262270, @zaks.anna wrote:

> I agree with Gabor. We should investigate how we can model the overflow on a 
> cast correctly.


Yes I agree with Gabor too. I meant this change as a temporary workaround only, 
I will investigate the modelling route and let you know.

Thanks!


http://reviews.llvm.org/D12901



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


[PATCH] D13557: Make locale code compile on Linux without GLIBC.

2015-10-08 Thread Vasileios Kalintiris via cfe-commits
vkalintiris created this revision.
vkalintiris added a reviewer: mclow.lists.
vkalintiris added a subscriber: cfe-commits.

Most of the #ifdefs in the locale code would check for the existence of
GLIBC or for operating systems other than Linux. This patch considers the
case where GLIBC isn't available on Linux, and allows the libcxx
library to build successfully when using the musl C library (with a
small patch for the extended locale functions strtoll_l() and
strtoull_l()).

http://reviews.llvm.org/D13557

Files:
  include/__locale
  src/locale.cpp

Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -812,7 +812,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 return isascii(c) ? ctype::__classic_upper_table()[c] : c;
 #else
 return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
@@ -825,7 +826,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 *low = isascii(*low) ? ctype::__classic_upper_table()[*low]
  : *low;
 #else
@@ -839,7 +841,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 return isascii(c) ? ctype::__classic_lower_table()[c] : c;
 #else
 return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
@@ -852,7 +855,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__linux__) || defined(__NetBSD__)
 *low = isascii(*low) ? ctype::__classic_lower_table()[*low]
  : *low;
 #else
@@ -921,8 +925,8 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_upper_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
-return isascii(c) ? 
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
+return isascii(c) ?
   static_cast(__classic_upper_table()[static_cast(c)]) : c;
 #else
 return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
@@ -938,7 +942,7 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_upper_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
 *low = isascii(*low) ?
   static_cast(__classic_upper_table()[static_cast(*low)]) : *low;
 #else
@@ -955,7 +959,7 @@
   static_cast(_DefaultRuneLocale.__maplower[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_lower_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
 return isascii(c) ?
   static_cast(__classic_lower_table()[static_cast(c)]) : c;
 #else
@@ -971,7 +975,7 @@
 *low = isascii(*low) ? static_cast(_DefaultRuneLocale.__maplower[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_lower_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__linux__) || defined(__EMSCRIPTEN__)
 *low = isascii(*low) ? static_cast(__classic_lower_table()[static_cast(*low)]) : *low;
 #else
 *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
@@ -1012,7 +1016,7 @@
 return low;
 }
 
-#ifdef __EMSCRIPTEN__
+#if !defined(__GLIBC__) && (defined(__linux__) || defined(__EMSCRIPTEN__))
 extern "C" const unsigned short ** __ctype_b_loc();
 extern "C" const int ** __ctype_tolower_loc();
 extern "C" const int ** __ctype_toupper_loc();
@@ -1114,7 +1118,7 @@
 return _ctype+1; // internal ctype mask table defined in msvcrt.dll
 // This is assumed to be safe, which is a nonsense assumption because we're
 // going to end up dereferencing it later...
-#elif defined(__EM

Re: [PATCH] D13407: [libcxx] Capture configuration information when installing the libc++ headers

2015-10-08 Thread Vasileios Kalintiris via cfe-commits
vkalintiris added a subscriber: vkalintiris.


Comment at: include/CMakeLists.txt:9
@@ -7,2 +8,3 @@
   PATTERN ".svn" EXCLUDE
+  PATTERN "__config_site.in" EXCLUDE
   ${LIBCXX_SUPPORT_HEADER_PATTERN}

Kind of silly but I believe that the files used for auto-generated config 
headers in LLVM have the extesions `.cmake` and `.in`, for cmake and autoconf, 
respectively.


http://reviews.llvm.org/D13407



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


Re: [PATCH] D13557: Make locale code compile on Linux without GLIBC.

2015-10-08 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.
jroelofs added a comment.

I don't think it's correct to say that `!defined(__GLIBC__) && 
defined(__linux__) ==> Musl` (nor is the converse true).  Unfortunately, Musl 
intentionally doesn't provide that sort of macro [1], so to provide support for 
Musl in libc++, we need to make note of it at configure-time via something like 
a _LIBCXX_LIBC_IS_MUSL macro via http://reviews.llvm.org/D13407.

1: http://www.openwall.com/lists/musl/2013/02/08/9


http://reviews.llvm.org/D13557



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


Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Great! I did not notice, that we already have exactly the same logic in 
SemaDeclAttr.cpp.
Maybe it would be possible even to refactor it in such a way that this code is 
written only once.

Adrian
> On Oct 8, 2015, at 6:53 AM, Aaron Ballman  wrote:
> 
> (Removing llvm-commits, adding cfe-commits)
> 
> On Wed, Oct 7, 2015 at 8:07 PM, Adrian Zgorzalek via llvm-commits
>  wrote:
>> Hey,
>> 
>> Here is an attempt to fix 
>> https://urldefense.proofpoint.com/v1/url?u=https://llvm.org/bugs/show_bug.cgi?id%3D25067&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=8P8ApMVHowVMPUxNPT7LA63ve6JJvA38Hc1rN4zEYvw%3D%0A&s=129aedfc04dd18acb23e1369c5712b619076e282e0a4e07452ac187e4d37d43a.
> 
> Thank you for working on this!
> 
>> 
>> Summary:
>> 
>> After introducing no_sanitize, we try to map no_sanitize_* into a
>> no_sanitize(“*”), the switch in code, however doesn’t handle cases when
>> attribute is surrounded by two underscores on each of the ends. In this
>> patch I am trying to utilize existing normalizeAttrName function, by
>> exposing it to outside world and using it before feeding input to the
>> switch.
>> 
>> Added unit tests for the crashes I encountered and patched.
> 
> I am hesitant to expose a normalized attribute name API like that
> because very little should ever care about the actual spelling string
> of the attribute; instead, it should be looking at the semantic
> spelling or the (parsed) attribute kind. However, the no sanitize
> attributes are a bit strange in that they don't have different
> semantic spellings, but instead use the list of sanitizers, so that
> approach won't work.
> 
> I think the better way to handle this is to refactor SemaDeclAttr.cpp
> to have a helper function named normalizeName() and use it in
> handleOwnershipAttr, handleFormatAttr, handleModeAttr, and
> handleNoSanitizeSpecificAttr. It can be used for normalizing attribute
> names as well as attribute argument names.
> 
> ~Aaron

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


r249698 - CGStmtOpenMP.cpp: Prune redundant \param. [-Wdocumentation]

2015-10-08 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Oct  8 11:41:42 2015
New Revision: 249698

URL: http://llvm.org/viewvc/llvm-project?rev=249698&view=rev
Log:
CGStmtOpenMP.cpp: Prune redundant \param. [-Wdocumentation]

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

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=249698&r1=249697&r2=249698&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Oct  8 11:41:42 2015
@@ -213,7 +213,6 @@ void CodeGenFunction::EmitOMPAggregateAs
 }
 
 /// \brief Emit initialization of arrays of complex types.
-/// \param Type Type of array.
 /// \param DestAddr Address of the array.
 /// \param Type Type of array.
 /// \param Init Initial expression of array.


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


Re: [PATCH] D13557: Make locale code compile on Linux without GLIBC.

2015-10-08 Thread Vasileios Kalintiris via cfe-commits
vkalintiris abandoned this revision.
vkalintiris added a comment.

In http://reviews.llvm.org/D13557#262801, @jroelofs wrote:

> Unfortunately, Musl intentionally doesn't provide that sort of macro [1], so 
> to provide support for Musl in libc++, we need to make note of it at 
> configure-time via something like a _LIBCXX_LIBC_IS_MUSL macro via 
> http://reviews.llvm.org/D13407.


Agreed. That would be much more elegant. I had to write another patch to test 
for the existence of *each* extended locale functions during 
configuration-time. It was generic but an ugly hack. Offering a 
_LIBCXX_LIBC_IS_MUSL option/macro would make things quite simpler. I'll abandon 
this review request and I'll wait until http://reviews.llvm.org/D13407 is 
committed.


http://reviews.llvm.org/D13557



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


Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Feedback applied, new patch in the attachment.

Adrian


> On Oct 8, 2015, at 8:48 AM, Adrian Zgorzalek  wrote:
>
> Great! I did not notice, that we already have exactly the same logic in 
> SemaDeclAttr.cpp.
> Maybe it would be possible even to refactor it in such a way that this code 
> is written only once.
>
> Adrian
>> On Oct 8, 2015, at 6:53 AM, Aaron Ballman  wrote:
>>
>> (Removing llvm-commits, adding cfe-commits)
>>
>> On Wed, Oct 7, 2015 at 8:07 PM, Adrian Zgorzalek via llvm-commits
>>  wrote:
>>> Hey,
>>>
>>> Here is an attempt to fix 
>>> https://urldefense.proofpoint.com/v1/url?u=https://llvm.org/bugs/show_bug.cgi?id%3D25067&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=8P8ApMVHowVMPUxNPT7LA63ve6JJvA38Hc1rN4zEYvw%3D%0A&s=129aedfc04dd18acb23e1369c5712b619076e282e0a4e07452ac187e4d37d43a.
>>
>> Thank you for working on this!
>>
>>>
>>> Summary:
>>>
>>> After introducing no_sanitize, we try to map no_sanitize_* into a
>>> no_sanitize(“*”), the switch in code, however doesn’t handle cases when
>>> attribute is surrounded by two underscores on each of the ends. In this
>>> patch I am trying to utilize existing normalizeAttrName function, by
>>> exposing it to outside world and using it before feeding input to the
>>> switch.
>>>
>>> Added unit tests for the crashes I encountered and patched.
>>
>> I am hesitant to expose a normalized attribute name API like that
>> because very little should ever care about the actual spelling string
>> of the attribute; instead, it should be looking at the semantic
>> spelling or the (parsed) attribute kind. However, the no sanitize
>> attributes are a bit strange in that they don't have different
>> semantic spellings, but instead use the list of sanitizers, so that
>> approach won't work.
>>
>> I think the better way to handle this is to refactor SemaDeclAttr.cpp
>> to have a helper function named normalizeName() and use it in
>> handleOwnershipAttr, handleFormatAttr, handleModeAttr, and
>> handleNoSanitizeSpecificAttr. It can be used for normalizing attribute
>> names as well as attribute argument names.
>>
>> ~Aaron
>



0001-Fix-ICE-in-Clang-when-dealing-with-attribute-__no_sa.patch
Description: 0001-Fix-ICE-in-Clang-when-dealing-with-attribute-__no_sa.patch
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249699 - Simplify DefaultCPU in ARMTargetInfo

2015-10-08 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Thu Oct  8 11:43:26 2015
New Revision: 249699

URL: http://llvm.org/viewvc/llvm-project?rev=249699&view=rev
Log:
Simplify DefaultCPU in ARMTargetInfo

Simplifying the convoluted CPU handling in ARMTargetInfo.

The default base CPU on ARM is ARM7TDMI, arch ARMv4T, and
ARMTargetInfo had a different one. This wasn't visible from
Clang because the driver selects the defaults and sets the
Arch/CPU features directly, but the constructor depended
on the CPU, which was never used.

This patch corrects the mistake and greatly simplifies
how CPU is dealt with (essentially by removing the duplicated
DefaultCPU field).

Tests updated.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249699&r1=249698&r2=249699&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 11:43:26 2015
@@ -4086,7 +4086,6 @@ class ARMTargetInfo : public TargetInfo
 
   std::string ABI, CPU;
 
-  StringRef DefaultCPU;
   StringRef CPUProfile;
   StringRef CPUAttr;
 
@@ -4097,7 +4096,7 @@ class ARMTargetInfo : public TargetInfo
   } FPMath;
 
   unsigned ArchISA;
-  unsigned ArchKind;
+  unsigned ArchKind = llvm::ARM::AK_ARMV4T;
   unsigned ArchProfile;
   unsigned ArchVersion;
 
@@ -4235,13 +4234,11 @@ class ARMTargetInfo : public TargetInfo
   void setArchInfo() {
 StringRef ArchName = getTriple().getArchName();
 
-ArchISA= llvm::ARM::parseArchISA(ArchName);
-DefaultCPU = getDefaultCPU(ArchName);
-
-unsigned ArchKind = llvm::ARM::parseArch(ArchName);
-if (ArchKind == llvm::ARM::AK_INVALID)
-  // set arch of the CPU, either provided explicitly or hardcoded default
-  ArchKind = llvm::ARM::parseCPUArch(CPU);
+ArchISA = llvm::ARM::parseArchISA(ArchName);
+CPU = llvm::ARM::getDefaultCPU(ArchName);
+unsigned AK = llvm::ARM::parseArch(ArchName);
+if (AK != llvm::ARM::AK_INVALID)
+  ArchKind = AK;
 setArchInfo(ArchKind);
   }
 
@@ -4262,8 +4259,7 @@ class ARMTargetInfo : public TargetInfo
   void setAtomic() {
 // when triple does not specify a sub arch, 
 // then we are not using inline atomics
-bool ShouldUseInlineAtomic = DefaultCPU.empty() ? 
- false :
+bool ShouldUseInlineAtomic =
(ArchISA == llvm::ARM::IK_ARM   && ArchVersion >= 6) ||
(ArchISA == llvm::ARM::IK_THUMB && ArchVersion >= 7);
 // Cortex M does not support 8 byte atomics, while general Thumb2 does. 
@@ -4291,10 +4287,6 @@ class ARMTargetInfo : public TargetInfo
 return CPUAttr.equals("6T2") || ArchVersion >= 7;
   }
 
-  StringRef getDefaultCPU(StringRef ArchName) const {
-return llvm::ARM::getDefaultCPU(ArchName);
-  }
-
   StringRef getCPUAttr() const {
 // For most sub-arches, the build attribute CPU name is enough.
 // For Cortex variants, it's slightly different.
@@ -4340,7 +4332,7 @@ class ARMTargetInfo : public TargetInfo
 
 public:
   ARMTargetInfo(const llvm::Triple &Triple, bool IsBigEndian)
-  : TargetInfo(Triple), CPU("arm1136j-s"), FPMath(FP_Default),
+  : TargetInfo(Triple), FPMath(FP_Default),
 IsAAPCS(true), LDREX(0), HW_FP(0) {
 BigEndian = IsBigEndian;
 
@@ -4353,7 +4345,7 @@ public:
   break;
 }
 
-// cache arch related info
+// Cache arch related info.
 setArchInfo();
 
 // {} in inline assembly are neon specifiers, not assembly variant
@@ -4389,8 +4381,8 @@ public:
 setABI("aapcs");
 break;
   case llvm::Triple::GNU:
-   setABI("apcs-gnu");
-   break;
+setABI("apcs-gnu");
+  break;
   default:
 if (Triple.getOS() == llvm::Triple::NetBSD)
   setABI("apcs-gnu");

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=249699&r1=249698&r2=249699&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Oct  8 11:43:26 2015
@@ -1198,7 +1198,7 @@
 // ARM:#define __APCS_32__ 1
 // ARM-NOT:#define __ARMEB__ 1
 // ARM:#define __ARMEL__ 1
-// ARM:#define __ARM_ARCH_6J__ 1
+// ARM:#define __ARM_ARCH_4T__ 1
 // ARM-NOT:#define __ARM_BIG_ENDIAN 1
 // ARM:#define __BIGGEST_ALIGNMENT__ 8
 // ARM:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
@@ -1338,7 +1338,6 @@
 // ARM:#define __SIZE_MAX__ 4294967295U
 // ARM:#define __SIZE_TYPE__ unsigned int
 // ARM:#define __SIZE_WIDTH__ 32
-// ARM:#define __THUMB_INTERWORK__ 1
 // ARM:#define __UINT16_C_SUFFIX__ {{$}}
 // ARM:#define __UINT16_MAX__ 65535
 // ARM:#define __UINT16_TYPE__ unsigned short
@@ -1389,7 +1388,7 @@
 // ARM-BE:#define __APCS_32__ 1
 // ARM-BE:#defi

Re: [PATCH] D13304: Avoid inlining in throw statement

2015-10-08 Thread via cfe-commits
> I think this actually makes it less general. You would presumably perform
> different inlining for:
>
>   throw f(x, y);
>
> versus
>
>   auto k = f(x, y);
>   throw k;

We need to differentiate between these two. For the second case, we should
not add any attribute because it’s not invoked in the EH region and it
could have any other purposes other than exception handling. I believe we
need to specifically handle only the case where we can guarantee that the
call is invoked only in exception handling context.


> That's not something we can really do from the frontend, because small
> constructors often don't look small until they themselves have been
> optimized.

I agree. If we need to add check for callee size, doing this in frontend
may not be the good idea. But it should be done before inliner.


> Would it be sufficient to mark just the invocation of __cxa_throw (or its
> equivalent) as cold? If the optimizer can't infer from that that the code
> leading up to the call is also cold, we should fix that in the LLVM-side
> analysis rather than working around it in the frontend.

Basically, current Inliner doesn't have any impact with Attribute::Cold
because ColdThreshold and InlineLimit are the same by default. I
understand noinline looks somewhat strong decision. But, even with
noinline, I believe we could expect more pros than cons.

In performance perspective, by avoiding inlining in throw statement, we
could open up more inline opportunities for functions containing throw
statements. For example, below small function could not be inlined in its
many callsites if the constructor of IndexOutOfBoundsException is
non-trivial and inlined first in elementAt().

  int elementAt(int idx) {
if (idx >= limit)
  throw IndexOutOfBoundsException(idx, limit);
return Array[idx];
  }
Pretty much same thing could actually happen in many c++ programs, and I
found the actual cases in spec2006/xalancbmk.

In most case we also don't need to increase code size by inlining
constructors invoked in throw statement, especially when there is a
hierarchy of exception handling classes.

The only downsides I can think of is the case where the constructor is
very small so that inlining it is profitable for size. My suggestion for
this is to move this implementation back to PruneEH.cpp so that we can
check the callee size right before the inliner. I may add the noinline
only when the constructor is large enough.




> On Wed, Oct 7, 2015 at 3:10 PM, Jun Bum Lim via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> junbuml added a comment.
>>
>> Thanks Richard for the comment.
>>
>> Initially, I intended to implement this in inliner by checking if a
>> callsite is in exception handling regions. However, I decided not to
>> implement this in inliner because this kind of check should be performed
>> for all callsites if we implement it in inliner.
>>
>> Instead of directly adding complexity in inliner, I implemented this in
>> PruneEH.cpp (http://reviews.llvm.org/D12979) because this is very
>> specific to exception handling regions. In this patch, I tried to mark
>> all
>> callsites invoked from throw statements as cold (noinline) by looking up
>> users of __cxa_throw() and __cxa_allocate_exception(). We had many
>> discussions and finally ended up to implement the same thing in clang to
>> be
>> more general and simpler as Hal suggested in
>> http://reviews.llvm.org/D12979.
>>
>
> I think this actually makes it less general. You would presumably perform
> different inlining for:
>
>   throw f(x, y);
>
> versus
>
>   auto k = f(x, y);
>   throw k;
>
> which doesn't really seem defensible.
>
>
>> As you point out, it should be done by influencing inline cost heurisic,
>> so I believe Attribute::Cold is the right attribute to be added here.
>> However, as I FIXMEed, the current ColdThreshold is not tuned yet
>> (r200898). So for now, I add both cold and noinline.
>>
>> Regarding code size, I believe not inlining contractor calls in throw
>> statements could be potentially more helpful for code size in many
>> cases.
>> If inlining very small callsites in throw statements could be issue,
>> then
>> we may be able to  check if callee is smaller than some threshold to
>> avoid
>> adding the attributes (cold and noinline).
>
>
> That's not something we can really do from the frontend, because small
> constructors often don't look small until they themselves have been
> optimized.
>
> Would it be sufficient to mark just the invocation of __cxa_throw (or its
> equivalent) as cold? If the optimizer can't infer from that that the code
> leading up to the call is also cold, we should fix that in the LLVM-side
> analysis rather than working around it in the frontend.
>

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


Re: [PATCH] D12832: [Driver] Add support for Windows 10 SDK

2015-10-08 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Looks like this got committed. Sorry for the delay, I was travelling.


http://reviews.llvm.org/D12832



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


r249704 - [clang-cl] Make /EHs turn on C++ EH once again

2015-10-08 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Oct  8 12:29:07 2015
New Revision: 249704

URL: http://llvm.org/viewvc/llvm-project?rev=249704&view=rev
Log:
[clang-cl] Make /EHs turn on C++ EH once again

C++ exceptions are still off by default, which is similar to how C++
cleanups are off by default in MSVC.

If you use clang instead of clang-cl, exceptions are also still off by
default. In the future, when C++ EH is proven to be stable, we may flip
the default for that driver to be consistent with other platforms.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-eh.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=249704&r1=249703&r2=249704&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct  8 12:29:07 2015
@@ -5392,10 +5392,6 @@ static EHFlags parseClangCLEHFlags(const
 }
   }
 
-  // FIXME: Disable C++ EH completely, until it becomes more reliable. Users
-  // can use -Xclang to manually enable C++ EH until then.
-  EH = EHFlags();
-
   return EH;
 }
 

Modified: cfe/trunk/test/Driver/cl-eh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-eh.cpp?rev=249704&r1=249703&r2=249704&view=diff
==
--- cfe/trunk/test/Driver/cl-eh.cpp (original)
+++ cfe/trunk/test/Driver/cl-eh.cpp Thu Oct  8 12:29:07 2015
@@ -1,11 +1,9 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
-// FIXME: When C++ EH works, we can make this flag turn things back on.
-
 // RUN: %clang_cl /c /EHsc -### -- %s 2>&1 | FileCheck -check-prefix=EHsc %s
-// EHsc-NOT: "-fcxx-exceptions"
-// EHsc-NOT: "-fexceptions"
+// EHsc: "-fcxx-exceptions"
+// EHsc: "-fexceptions"
 
 // RUN: %clang_cl /c /EHs-c- -### -- %s 2>&1 | FileCheck -check-prefix=EHs_c_ 
%s
 // EHs_c_-NOT: "-fcxx-exceptions"
@@ -16,12 +14,12 @@
 // EHs_EHc_-NOT: "-fexceptions"
 
 // RUN: %clang_cl /c /EHs- /EHs -### -- %s 2>&1 | FileCheck 
-check-prefix=EHs_EHs %s
-// EHs_EHs-NOT: "-fcxx-exceptions"
-// EHs_EHs-NOT: "-fexceptions"
+// EHs_EHs: "-fcxx-exceptions"
+// EHs_EHs: "-fexceptions"
 
 // RUN: %clang_cl /c /EHs- /EHsa -### -- %s 2>&1 | FileCheck 
-check-prefix=EHs_EHa %s
-// EHs_EHa-NOT: "-fcxx-exceptions"
-// EHs_EHa-NOT: "-fexceptions"
+// EHs_EHa: "-fcxx-exceptions"
+// EHs_EHa: "-fexceptions"
 
 // RUN: %clang_cl /c /EHinvalid -### -- %s 2>&1 | FileCheck 
-check-prefix=EHinvalid %s
 // EHinvalid: error: invalid value 'invalid' in '/EH'


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


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

2015-10-08 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> Even if you do not deal with this case I think it would be great to have an 
> XFAIL test with a fixme that describes this limitation.


Yes! Every time we have a test case that shows known limitations, we should add 
it to the regression tests with a TODO explaining the issue. (I would not add 
it as a separate test that is XFAILed but rather add to an existing test file 
at the very end in the TODO or FIXME section. )


http://reviews.llvm.org/D13099



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


Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread Reid Kleckner via cfe-commits
rnk added a comment.

I added this conditional check in r221415, with this message:

  cmake: Only export targets in the standalone build
  
  Trying to fix bots that didn't like the fact that I exported targets
  that depended on LLVM without exporting targets from LLVM.

I assume this has already been addressed in LLVM? We now export targets there 
so we can depend on them in clang's exported targets file? If so, I'm happy to 
make this check simply conditional on the CMake version like you suggest.

I'm not actually a good reviewer for these kinds of things, I know very little 
about cmake package exports. =/ When I made this code change, I was just trying 
to hack the standalone build into shape. I haven't really used it since.


http://reviews.llvm.org/D13453



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


Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-08 Thread Chris Bieneman via cfe-commits
beanz added inline comments.


Comment at: runtime/CMakeLists.txt:41
@@ +40,3 @@
+
+  add_custom_target(compiler-rt-clear
+DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared

samsonov wrote:
> So, that's the target that you can invoke manually to clean compiler-rt build?
Yes.


Comment at: runtime/CMakeLists.txt:46
@@ +45,3 @@
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared
+DEPENDS clang llvm-config
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}

samsonov wrote:
> Hm? But "compiler-rt" target also depends on clang and llvm-config.
It should. We need it to rebuild whenever clang and llvm-config change.

Although it just occurred to me that I also need to make sure that the clearing 
happens before compiler-rt gets built, so there will need to be a dependency on 
that too... I'll figure that out.


Comment at: runtime/CMakeLists.txt:69
@@ -47,3 +68,3 @@
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-   -DCOMPILER_RT_ENABLE_WERROR=ON
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""

samsonov wrote:
> I thought we only refer to COMPILER_RT_INSTALL_PATH in compiler-rt's CMake. 
> Do we actually need CMAKE_INSTALL_PREFIX there as well?
I don't think we're actually using it in compiler-rt today, but I think that 
passing it through is a good idea so that if in the future compiler-rt ever 
uses CMAKE_INSTALL_PREFIX it will be properly populated.


Comment at: runtime/CMakeLists.txt:70
@@ -49,2 +69,3 @@
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build

samsonov wrote:
> Disagree - we can't set COMPILER_RT_ENABLE_WERROR in compiler-rt's CMake, 
> because standalone compiler-rt can be built with any compiler in the world, 
> which we don't control. OTOH, if we *know* we're building it with trunk 
> Clang, having it -Werror-clean is smth. we can enforce. It's also consistent 
> with what autoconf did previously.
At the very least if we do that it should be tied to LLVM_ENABLE_WERROR, not 
just defaulted to On. None of our projects default WERROR to On anywhere. While 
I agree building with Werror is desirable, we shouldn't be defaulting it on, 
and we certainly shouldn't be doing it in a way that makes it so the user has 
to edit the build files in order to turn it off.


Comment at: runtime/CMakeLists.txt:78
@@ -62,11 +77,3 @@
 
-  ExternalProject_Add_Step(compiler-rt clobber
-COMMAND ${CMAKE_COMMAND} -E remove_directory 
-COMMAND ${CMAKE_COMMAND} -E make_directory 
-COMMENT "Clobberring compiler-rt build directory..."
-DEPENDERS configure
-DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-  )
-
-  ExternalProject_Get_Property(compiler-rt BINARY_DIR)
-  set(COMPILER_RT_BINARY_DIR ${BINARY_DIR})
+  add_custom_target(install-compiler-rt
+DEPENDS compiler-rt

samsonov wrote:
> This is also convenience target, right?
Yes.


http://reviews.llvm.org/D13399



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


[PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, sbenza.
aaron.ballman added a subscriber: cfe-commits.

setjmp and longjmp facilities in C++ are unsafe due to the likelihood of 
triggering undefined behavior with nontrivial type destruction, etc. Instead, 
exception handling facilities are a better choice. This patch adds a checker 
that discourages the use of setjmp and longjmp in C++.

This patch corresponds to CERT C++ Coding Standard rule: 
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834

http://reviews.llvm.org/D13567

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/SetLongJmpCheck.cpp
  clang-tidy/cert/SetLongJmpCheck.h
  docs/clang-tidy/checks/cert-setlongjmp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-setlongjmp.cpp

Index: test/clang-tidy/cert-setlongjmp.cpp
===
--- test/clang-tidy/cert-setlongjmp.cpp
+++ test/clang-tidy/cert-setlongjmp.cpp
@@ -0,0 +1,26 @@
+// RUN: %python %S/check_clang_tidy.py %s cert-err52-cpp %t -- -std=c++11
+
+typedef void *jmp_buf;
+extern int __setjmpimpl(jmp_buf);
+#define setjmp(x) __setjmpimpl(x)
+[[noreturn]] extern void longjmp(jmp_buf, int);
+
+namespace std {
+using ::jmp_buf;
+using ::longjmp;
+}
+
+static jmp_buf env;
+void g() {
+  std::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead [cert-err52-cpp]
+  ::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+  longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+}
+
+void f() {
+  (void)setjmp(env);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not call 'setjmp'; consider using exception handling instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::
+   cert-setlongjmp
cert-variadic-function-def
cppcoreguidelines-pro-type-const-cast
cppcoreguidelines-pro-type-reinterpret-cast
Index: docs/clang-tidy/checks/cert-setlongjmp.rst
===
--- docs/clang-tidy/checks/cert-setlongjmp.rst
+++ docs/clang-tidy/checks/cert-setlongjmp.rst
@@ -0,0 +1,11 @@
+cert-err52-cpp
+==
+
+The C standard library facilities setjmp() and longjmp() can be used to
+simulate throwing and catching exceptions. However, these facilities bypass
+automatic resource management and can result in undefined behavior, commonly
+including resource leaks, and denial-of-service attacks.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`ERR52-CPP. Do not use setjmp() or longjmp()
+`_.
Index: clang-tidy/cert/SetLongJmpCheck.h
===
--- clang-tidy/cert/SetLongJmpCheck.h
+++ clang-tidy/cert/SetLongJmpCheck.h
@@ -0,0 +1,37 @@
+//===--- SetLongJmpCheck.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_SETLONGJMPCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Guards against use of setjmp/longjmp in C++ code
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-setlongjmp.html
+class SetLongJmpCheck : public ClangTidyCheck {
+public:
+  SetLongJmpCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void registerPPCallbacks(CompilerInstance &Compiler) override;
+
+  static const char DiagWording[];
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
Index: clang-tidy/cert/SetLongJmpCheck.cpp
===
--- clang-tidy/cert/SetLongJmpCheck.cpp
+++ clang-tidy/cert/SetLongJmpCheck.cpp
@@ -0,0 +1,80 @@
+//===--- SetLongJmpCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-10-08 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 36880.
sfantao added a comment.

Use class instead of structs if aggregate have private or protected fields.


http://reviews.llvm.org/D12614

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/LangOptions.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_global_capture.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_messages.cpp

Index: test/OpenMP/target_messages.cpp
===
--- test/OpenMP/target_messages.cpp
+++ test/OpenMP/target_messages.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -omptargets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s
+// CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
 
 void foo() {
 }
Index: test/OpenMP/target_codegen_registration.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen_registration.cpp
@@ -0,0 +1,437 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
+
+// Check that no target code is emmitted if no omptests flag was provided.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NTARGET
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[SA:%.+]] = type { [4 x i32] }
+// CHECK-DAG: [[SB:%.+]] = type { [8 x i32] }
+// CHECK-DAG: [[SC:%.+]] = type { [16 x i32] }
+// CHECK-DAG: [[SD:%.+]] = type { [32 x i32] }
+// CHECK-DAG: [[SE:%.+]] = type { [64 x i32] }
+// CHECK-DAG: [[ST1:%.+]] = type { [228 x i32] }
+// CHECK-DAG: [[ST2:%.+]] = type { [1128 x i32] }
+// CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]] }
+// CHECK-DAG: [[DEVTY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
+// CHECK-DAG: [[DSCTY:%.+]] = type { i32, [[DEVTY]]*, [[ENTTY]]*, [[ENTTY]]* }
+
+// TCHECK:[[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]] }
+
+// CHECK-DAG: [[A1:@.+]] = internal global [[SA]]
+// CHECK-DAG: [[A2:@.+]] = glob

Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-10-08 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Thanks for the comments!



Comment at: lib/CodeGen/CGOpenMPRuntime.h:323
@@ +322,3 @@
+  /// far.
+  struct OffloadEntriesInfoManagerTy {
+CodeGenModule &CGM;

ABataev wrote:
> Maybe it is better to make it a class if it has some non-public members?
Ok, replaced struct by class in `OffloadEntriesInfoManagerTy` and the other 
subtypes that have either private or protected fields.



http://reviews.llvm.org/D12614



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


Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
> Feedback applied, new patch in the attachment.

Thank you for working on this! A few comments:

> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
> Date: Wed, 7 Oct 2015 15:55:53 -0700
> Subject: [PATCH] Fix ICE in Clang when dealing with
>  attribute(__no_sanitize_*__)
>
> Summary:
>
> Both syntaxes: __attribute__((no_sanitize_address)) and
> __attribute__((__no_sanitize__address__)) are valid, following
> documentation:
>
> > The attribute identifier (but not scope) can also be specified with a
> > preceding and following __ (double underscore) to avoid interference
> > from a macro with the same name. For instance, gnu::__const__ can be
> > used instead of gnu::const.
>
> This patch is fixing ICE when __const__ syntax is used.
>
> Test Plan:
>
> Added unittests in the patch which cover these cases. After applying
> this patch they don't crash anymore.
> ---
>  lib/Sema/SemaDeclAttr.cpp | 28 +---
>  test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
>  test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
>  test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
>  4 files changed, 23 insertions(+), 11 deletions(-)

FWIW, it's usually better to supply svn patches instead of git patches
(my vcs has troubles applying patches like this).

>
> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
> index 3cf9567..b2f2cff 100644
> --- a/lib/Sema/SemaDeclAttr.cpp
> +++ b/lib/Sema/SemaDeclAttr.cpp
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange AttrRange, 
> Decl *D, Expr *E,
>  AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
>  }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeAttrName(StringRef& AttrName) {

I would prefer this be called normalizeName since it doesn't just
normalize attribute names (for instance, this is used to normalize
attribute arguments as well).

> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Too short attribute name");

"Name too short" instead.

> +AttrName = AttrName.substr(2, AttrName.size() - 4);

I prefer: drop_front() and drop_back() instead.

> +return true;
> +  }
> +  return false;
> +}
> +
>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
>// This attribute must be applied to a function declaration. The first
>// argument to the attribute must be an identifier, the name of the 
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D, 
> const AttributeList &AL) {
>
>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeAttrName(ModuleName)) {
>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>}
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const 
> AttributeList &Attr) {
>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeAttrName(Format)) {
>  // If we've modified the string name, we need a new identifier for it.
>  II = &S.Context.Idents.get(Format);
>}
> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const 
> AttributeList &Attr) {
>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>StringRef Str = Name->getName();
>
> -  // Normalize the attribute name, __foo__ becomes foo.
> -  if (Str.startswith("__") && Str.endswith("__"))
> -Str = Str.substr(2, Str.size() - 4);
> +  static_cast(normalizeAttrName(Str));

No need for the static_cast to void here; we're okay ignoring this
return value implicitly.

>
>unsigned DestWidth = 0;
>bool IntegerMode = true;
> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S, Decl *D, 
> const AttributeList &Attr) {
>
>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>   const AttributeList &Attr) {
> +  StringRef AttrName = Attr.getName()->getName();
> +  static_cast(normalizeAttrName(AttrName));

No need for the static_cast here either.

~Aaron

>std::string SanitizerName =
> -  llvm::StringSwitch(Attr.getName()->getName())
> +  llvm::StringSwitch(AttrName)
>.Case("no_address_safety_analysis", "address")
>.Case("no_sanitize_address", "address")
>.Case("no_sanitize_thread", "thread")
> diff --git a/test/Sem

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 2:33 PM, Adrian Zgorzalek  wrote:
> I so much like this fast review cycle :)

I aim to please. ;-)

>
> Comments applied.

LGTM with one nit:

+static bool normalizeName(StringRef& AttrName) {

Should be (StringRef &AttrName) per style guidelines. A good idea is
to run clang-format over the patch or modified code, that fixes these
sort of things handily.

Thanks!

~Aaron

>
> Adrian
>
>
>> On Oct 8, 2015, at 11:24 AM, Aaron Ballman  wrote:
>>
>> On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
>>> Feedback applied, new patch in the attachment.
>>
>> Thank you for working on this! A few comments:
>>
>>> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
>>> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
>>> Date: Wed, 7 Oct 2015 15:55:53 -0700
>>> Subject: [PATCH] Fix ICE in Clang when dealing with
>>> attribute(__no_sanitize_*__)
>>>
>>> Summary:
>>>
>>> Both syntaxes: __attribute__((no_sanitize_address)) and
>>> __attribute__((__no_sanitize__address__)) are valid, following
>>> documentation:
>>>
 The attribute identifier (but not scope) can also be specified with a
 preceding and following __ (double underscore) to avoid interference
 from a macro with the same name. For instance, gnu::__const__ can be
 used instead of gnu::const.
>>>
>>> This patch is fixing ICE when __const__ syntax is used.
>>>
>>> Test Plan:
>>>
>>> Added unittests in the patch which cover these cases. After applying
>>> this patch they don't crash anymore.
>>> ---
>>> lib/Sema/SemaDeclAttr.cpp | 28
>>> +---
>>> test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
>>> test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
>>> test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
>>> 4 files changed, 23 insertions(+), 11 deletions(-)
>>
>> FWIW, it's usually better to supply svn patches instead of git patches
>> (my vcs has troubles applying patches like this).
>>
>>>
>>> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
>>> index 3cf9567..b2f2cff 100644
>>> --- a/lib/Sema/SemaDeclAttr.cpp
>>> +++ b/lib/Sema/SemaDeclAttr.cpp
>>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange
>>> AttrRange, Decl *D, Expr *E,
>>> AssumeAlignedAttr(AttrRange, Context, E, OE,
>>> SpellingListIndex));
>>> }
>>>
>>> +/// Normalize the attribute, __foo__ becomes foo.
>>> +/// Returns true if normalization was applied.
>>> +static bool normalizeAttrName(StringRef& AttrName) {
>>
>> I would prefer this be called normalizeName since it doesn't just
>> normalize attribute names (for instance, this is used to normalize
>> attribute arguments as well).
>>
>>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>>> +assert(AttrName.size() > 4 && "Too short attribute name");
>>
>> "Name too short" instead.
>>
>>> +AttrName = AttrName.substr(2, AttrName.size() - 4);
>>
>> I prefer: drop_front() and drop_back() instead.
>>
>>> +return true;
>>> +  }
>>> +  return false;
>>> +}
>>> +
>>> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>>> &AL) {
>>>   // This attribute must be applied to a function declaration. The first
>>>   // argument to the attribute must be an identifier, the name of the
>>> resource,
>>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D,
>>> const AttributeList &AL) {
>>>
>>>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>>
>>> -  // Normalize the argument, __foo__ becomes foo.
>>>   StringRef ModuleName = Module->getName();
>>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>>> -  ModuleName.size() > 4) {
>>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>>> +  if (normalizeAttrName(ModuleName)) {
>>> Module = &S.PP.getIdentifierTable().get(ModuleName);
>>>   }
>>>
>>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D,
>>> const AttributeList &Attr) {
>>>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Format = II->getName();
>>>
>>> -  // Normalize the argument, __foo__ becomes foo.
>>> -  if (Format.startswith("__") && Format.endswith("__")) {
>>> -Format = Format.substr(2, Format.size() - 4);
>>> +  if (normalizeAttrName(Format)) {
>>> // If we've modified the string name, we need a new identifier for
>>> it.
>>> II = &S.Context.Idents.get(Format);
>>>   }
>>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const
>>> AttributeList &Attr) {
>>>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Str = Name->getName();
>>>
>>> -  // Normalize the attribute name, __foo__ becomes foo.
>>> -  if (Str.startswith("__") && Str.endswith("__"))
>>> -Str = Str.substr(2, Str.size() - 4);
>>> +  static_cast(normalizeAttrName(Str));
>>
>> No need for the static_cast to void here; we're okay ignoring this
>> return value implicitly.
>>
>>>
>>>   unsigned DestWidth = 0;
>>>   bool IntegerMode = true;
>>> @@ -4533,

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
I so much like this fast review cycle :)

Comments applied.

Adrian


> On Oct 8, 2015, at 11:24 AM, Aaron Ballman  wrote:
>
> On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
>> Feedback applied, new patch in the attachment.
>
> Thank you for working on this! A few comments:
>
>> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
>> Date: Wed, 7 Oct 2015 15:55:53 -0700
>> Subject: [PATCH] Fix ICE in Clang when dealing with
>> attribute(__no_sanitize_*__)
>>
>> Summary:
>>
>> Both syntaxes: __attribute__((no_sanitize_address)) and
>> __attribute__((__no_sanitize__address__)) are valid, following
>> documentation:
>>
>>> The attribute identifier (but not scope) can also be specified with a
>>> preceding and following __ (double underscore) to avoid interference
>>> from a macro with the same name. For instance, gnu::__const__ can be
>>> used instead of gnu::const.
>>
>> This patch is fixing ICE when __const__ syntax is used.
>>
>> Test Plan:
>>
>> Added unittests in the patch which cover these cases. After applying
>> this patch they don't crash anymore.
>> ---
>> lib/Sema/SemaDeclAttr.cpp | 28 +---
>> test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
>> test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
>> test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
>> 4 files changed, 23 insertions(+), 11 deletions(-)
>
> FWIW, it's usually better to supply svn patches instead of git patches
> (my vcs has troubles applying patches like this).
>
>>
>> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
>> index 3cf9567..b2f2cff 100644
>> --- a/lib/Sema/SemaDeclAttr.cpp
>> +++ b/lib/Sema/SemaDeclAttr.cpp
>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange 
>> AttrRange, Decl *D, Expr *E,
>> AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
>> }
>>
>> +/// Normalize the attribute, __foo__ becomes foo.
>> +/// Returns true if normalization was applied.
>> +static bool normalizeAttrName(StringRef& AttrName) {
>
> I would prefer this be called normalizeName since it doesn't just
> normalize attribute names (for instance, this is used to normalize
> attribute arguments as well).
>
>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> +assert(AttrName.size() > 4 && "Too short attribute name");
>
> "Name too short" instead.
>
>> +AttrName = AttrName.substr(2, AttrName.size() - 4);
>
> I prefer: drop_front() and drop_back() instead.
>
>> +return true;
>> +  }
>> +  return false;
>> +}
>> +
>> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
>>   // This attribute must be applied to a function declaration. The first
>>   // argument to the attribute must be an identifier, the name of the 
>> resource,
>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D, 
>> const AttributeList &AL) {
>>
>>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>>   StringRef ModuleName = Module->getName();
>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> -  ModuleName.size() > 4) {
>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>> +  if (normalizeAttrName(ModuleName)) {
>> Module = &S.PP.getIdentifierTable().get(ModuleName);
>>   }
>>
>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const 
>> AttributeList &Attr) {
>>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>   StringRef Format = II->getName();
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>> -  if (Format.startswith("__") && Format.endswith("__")) {
>> -Format = Format.substr(2, Format.size() - 4);
>> +  if (normalizeAttrName(Format)) {
>> // If we've modified the string name, we need a new identifier for it.
>> II = &S.Context.Idents.get(Format);
>>   }
>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const 
>> AttributeList &Attr) {
>>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>   StringRef Str = Name->getName();
>>
>> -  // Normalize the attribute name, __foo__ becomes foo.
>> -  if (Str.startswith("__") && Str.endswith("__"))
>> -Str = Str.substr(2, Str.size() - 4);
>> +  static_cast(normalizeAttrName(Str));
>
> No need for the static_cast to void here; we're okay ignoring this
> return value implicitly.
>
>>
>>   unsigned DestWidth = 0;
>>   bool IntegerMode = true;
>> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S, Decl *D, 
>> const AttributeList &Attr) {
>>
>> static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>>  const AttributeList &Attr) {
>> +  StringRef AttrName = Attr.getName()->getName();
>> +  static_cast(normalizeAttrName(AttrName));
>
> No need for the static_cast here either.
>
> ~Aaron
>
>>   std::string SanitizerName =
>> -  llvm::StringSwitch(Attr.getName()-

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Marshall Clow via cfe-commits
On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith  wrote:

> . This one is tricky:
>
> 1) There's an (undocumented) interface between the C standard library and
> this header, where the macros __need_ptrdiff_t, __need_size_t,
> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this
> header rather than the whole thing. If we see any of those, just go
> straight to the underlying header.
>

Ok, but in that case we don't get nullptr.  I suspect that's OK.


> 2) We probably don't want  to include  (for consistency
> with other headers)
>

No, we do not! :-)


> , but  must provide a ::nullptr_t (which we don't want 
> to provide). So neither header includes the other. Instead, both include
> <__nullptr> for std::nullptr_t, and we duplicate the definition of
> max_align_t between them, in the case where the compiler's 
> doesn't provide it.
>
> If you prefer, I could make  include  to avoid the
> duplication of the max_align_t logic.
>

No; this is a minor annoyance, and layer jumping ( including
) is a major annoyance - and I'm pretty sure that that would come
back to bite us in the future.

Looks ok to me.

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


Re: [PATCH] D13525: [CodeGen] Attach function attributes to functions created in CGBlocks.cpp.

2015-10-08 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 36886.
ahatanak added a comment.

Changed CodeGenModule::SetLLVMFunctionAttributesForDefinition to use early 
return.

I'll first commit the NFC patch to fix 
CodeGenModule::SetLLVMFunctionAttributesForDefinition and commit the rest after 
that.


http://reviews.llvm.org/D13525

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenObjC/arc-blocks.m

Index: test/CodeGenObjC/arc-blocks.m
===
--- test/CodeGenObjC/arc-blocks.m
+++ test/CodeGenObjC/arc-blocks.m
@@ -43,7 +43,7 @@
   extern void test2_helper(id (^)(void));
   test2_helper(^{ return x; });
 
-// CHECK-LABEL:define internal void @__copy_helper_block_
+// CHECK-LABEL:define internal void @__copy_helper_block_(i8*, i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[SRC:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8**
@@ -53,7 +53,7 @@
 // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) [[NUW]]
 // CHECK-NEXT: ret void
 
-// CHECK-LABEL:define internal void @__destroy_helper_block_
+// CHECK-LABEL:define internal void @__destroy_helper_block_(i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[T1]], i32 0, i32 5
@@ -134,16 +134,16 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[T1]]
   // CHECK-NEXT: store i8* [[T2]], i8** [[T0]]
   // CHECK-NEXT: store i8* null, i8** [[T1]]
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]]
   // CHECK-NEXT: call void @objc_release(i8* [[T1]])
@@ -155,10 +155,10 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
 }
 
@@ -221,27 +221,27 @@
   // CHECK-NEXT: call void @llvm.lifetime.end(i64 48, i8* [[VARPTR2]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]])
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
 
   // CHECK-LABEL:define internal void @__test6_block_invoke
   // CHECK:  [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
   // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
   // CHECK:  call void

Re: [PATCH] D13453: Always generate cmake config files

2015-10-08 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 36889.
hintonda added a comment.

- add back check for standalone and add cmake version


http://reviews.llvm.org/D13453

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,7 +550,7 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
+if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_GREATER 3)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, 
but
   # the usual CMake convention seems to be ${Project}Targets.cmake.


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,7 +550,7 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
+if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_GREATER 3)
   # Generate a list of CMake library targets so that other CMake projects can
   # link against them. LLVM calls its version of this file LLVMExports.cmake, but
   # the usual CMake convention seems to be ${Project}Targets.cmake.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Run clang-format, diff is in SVN format.

Please, can you commit on behalf of me unless you are willing to grant me write 
permission to the repo ;-)

Adrian


> On Oct 8, 2015, at 11:40 AM, Aaron Ballman  wrote:
>
> On Thu, Oct 8, 2015 at 2:33 PM, Adrian Zgorzalek  wrote:
>> I so much like this fast review cycle :)
>
> I aim to please. ;-)
>
>>
>> Comments applied.
>
> LGTM with one nit:
>
> +static bool normalizeName(StringRef& AttrName) {
>
> Should be (StringRef &AttrName) per style guidelines. A good idea is
> to run clang-format over the patch or modified code, that fixes these
> sort of things handily.
>
> Thanks!
>
> ~Aaron
>
>>
>> Adrian
>>
>>
>>> On Oct 8, 2015, at 11:24 AM, Aaron Ballman  wrote:
>>>
>>> On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
 Feedback applied, new patch in the attachment.
>>>
>>> Thank you for working on this! A few comments:
>>>
 From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
 Date: Wed, 7 Oct 2015 15:55:53 -0700
 Subject: [PATCH] Fix ICE in Clang when dealing with
 attribute(__no_sanitize_*__)

 Summary:

 Both syntaxes: __attribute__((no_sanitize_address)) and
 __attribute__((__no_sanitize__address__)) are valid, following
 documentation:

> The attribute identifier (but not scope) can also be specified with a
> preceding and following __ (double underscore) to avoid interference
> from a macro with the same name. For instance, gnu::__const__ can be
> used instead of gnu::const.

 This patch is fixing ICE when __const__ syntax is used.

 Test Plan:

 Added unittests in the patch which cover these cases. After applying
 this patch they don't crash anymore.
 ---
 lib/Sema/SemaDeclAttr.cpp | 28
 +---
 test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
 test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
 test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
 4 files changed, 23 insertions(+), 11 deletions(-)
>>>
>>> FWIW, it's usually better to supply svn patches instead of git patches
>>> (my vcs has troubles applying patches like this).
>>>

 diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
 index 3cf9567..b2f2cff 100644
 --- a/lib/Sema/SemaDeclAttr.cpp
 +++ b/lib/Sema/SemaDeclAttr.cpp
 @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange
 AttrRange, Decl *D, Expr *E,
AssumeAlignedAttr(AttrRange, Context, E, OE,
 SpellingListIndex));
 }

 +/// Normalize the attribute, __foo__ becomes foo.
 +/// Returns true if normalization was applied.
 +static bool normalizeAttrName(StringRef& AttrName) {
>>>
>>> I would prefer this be called normalizeName since it doesn't just
>>> normalize attribute names (for instance, this is used to normalize
>>> attribute arguments as well).
>>>
 +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
 +assert(AttrName.size() > 4 && "Too short attribute name");
>>>
>>> "Name too short" instead.
>>>
 +AttrName = AttrName.substr(2, AttrName.size() - 4);
>>>
>>> I prefer: drop_front() and drop_back() instead.
>>>
 +return true;
 +  }
 +  return false;
 +}
 +
 static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
 &AL) {
  // This attribute must be applied to a function declaration. The first
  // argument to the attribute must be an identifier, the name of the
 resource,
 @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl *D,
 const AttributeList &AL) {

  IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;

 -  // Normalize the argument, __foo__ becomes foo.
  StringRef ModuleName = Module->getName();
 -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
 -  ModuleName.size() > 4) {
 -ModuleName = ModuleName.drop_front(2).drop_back(2);
 +  if (normalizeAttrName(ModuleName)) {
Module = &S.PP.getIdentifierTable().get(ModuleName);
  }

 @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
  IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
  StringRef Format = II->getName();

 -  // Normalize the argument, __foo__ becomes foo.
 -  if (Format.startswith("__") && Format.endswith("__")) {
 -Format = Format.substr(2, Format.size() - 4);
 +  if (normalizeAttrName(Format)) {
// If we've modified the string name, we need a new identifier for
 it.
II = &S.Context.Idents.get(Format);
  }
 @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl *D, const
 AttributeList &Attr) {
  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
  StringRef Str = Name->getName();

 -  // Normalize the attribute name, __

r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Oct  8 14:24:08 2015
New Revision: 249721

URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
Log:
When mapping no_sanitize_* attributes to no_sanitize attributes, handle 
GNU-style formatting that involves prefix and suffix underscores. Cleans up 
other usages of similar functionality.

Patch by Adrian Zgorzalek!

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
@@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
 AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
 }
 
+/// Normalize the attribute, __foo__ becomes foo.
+/// Returns true if normalization was applied.
+static bool normalizeName(StringRef &AttrName) {
+  if (AttrName.startswith("__") && AttrName.endswith("__")) {
+assert(AttrName.size() > 4 && "Name too short");
+AttrName = AttrName.drop_front(2).drop_back(2);
+return true;
+  }
+  return false;
+}
+
 static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // This attribute must be applied to a function declaration. The first
   // argument to the attribute must be an identifier, the name of the resource,
@@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
 
   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
 
-  // Normalize the argument, __foo__ becomes foo.
   StringRef ModuleName = Module->getName();
-  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
-  ModuleName.size() > 4) {
-ModuleName = ModuleName.drop_front(2).drop_back(2);
+  if (normalizeName(ModuleName)) {
 Module = &S.PP.getIdentifierTable().get(ModuleName);
   }
 
@@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
   StringRef Format = II->getName();
 
-  // Normalize the argument, __foo__ becomes foo.
-  if (Format.startswith("__") && Format.endswith("__")) {
-Format = Format.substr(2, Format.size() - 4);
+  if (normalizeName(Format)) {
 // If we've modified the string name, we need a new identifier for it.
 II = &S.Context.Idents.get(Format);
   }
@@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
   StringRef Str = Name->getName();
 
-  // Normalize the attribute name, __foo__ becomes foo.
-  if (Str.startswith("__") && Str.endswith("__"))
-Str = Str.substr(2, Str.size() - 4);
+  normalizeName(Str);
 
   unsigned DestWidth = 0;
   bool IntegerMode = true;
@@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
 
 static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
  const AttributeList &Attr) {
+  StringRef AttrName = Attr.getName()->getName();
+  normalizeName(AttrName);
   std::string SanitizerName =
-  llvm::StringSwitch(Attr.getName()->getName())
+  llvm::StringSwitch(AttrName)
   .Case("no_address_safety_analysis", "address")
   .Case("no_sanitize_address", "address")
   .Case("no_sanitize_thread", "thread")

Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp?rev=249721&r1=249720&r2=249721&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp Thu Oct  8 14:24:08 2015
@@ -5,12 +5,14 @@
 #if !__has_attribute(no_sanitize_address)
 #error "Should support no_sanitize_address"
 #endif
-
-void noanal_fun() NO_SANITIZE_ADDRESS;
-
-void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
-  // expected-error {{'no_sanitize_address' attribute takes no arguments}}
-
+
+void noanal_fun() NO_SANITIZE_ADDRESS;
+
+void noanal_fun_alt() __attribute__((__no_sanitize_address__));
+
+void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
+  // expected-error {{'no_sanitize_address' attribute takes no arguments}}
+
 int noanal_testfn(int y) NO_SANITIZE_ADDRESS;
 
 int noanal_testfn(int y) {

Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp?rev=249721&r1=249720&r2=249721&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp (original)
+++ cfe/trunk/test/Sem

Re: [PATCH] Fix ICE in Clang when dealing with attribute(__no_sanitize_*__)

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 2:50 PM, Adrian Zgorzalek  wrote:
> Run clang-format, diff is in SVN format.
>
> Please, can you commit on behalf of me unless you are willing to grant me
> write permission to the repo ;-)

Thanks! I've commit in r249721. As for repo permissions, if you are
intending to contribute with some frequency, you can talk to Chris
Lattner about the process of getting an svn login.

~Aaron

>
> Adrian
>
>
>> On Oct 8, 2015, at 11:40 AM, Aaron Ballman  wrote:
>>
>> On Thu, Oct 8, 2015 at 2:33 PM, Adrian Zgorzalek  wrote:
>>> I so much like this fast review cycle :)
>>
>> I aim to please. ;-)
>>
>>>
>>> Comments applied.
>>
>> LGTM with one nit:
>>
>> +static bool normalizeName(StringRef& AttrName) {
>>
>> Should be (StringRef &AttrName) per style guidelines. A good idea is
>> to run clang-format over the patch or modified code, that fixes these
>> sort of things handily.
>>
>> Thanks!
>>
>> ~Aaron
>>
>>>
>>> Adrian
>>>
>>>
 On Oct 8, 2015, at 11:24 AM, Aaron Ballman 
 wrote:

 On Thu, Oct 8, 2015 at 12:46 PM, Adrian Zgorzalek  wrote:
> Feedback applied, new patch in the attachment.

 Thank you for working on this! A few comments:

> From 13f4df6def5f26768f9ea048e013f779bb4a7814 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Adrian=20Zgorza=C5=82ek?= 
> Date: Wed, 7 Oct 2015 15:55:53 -0700
> Subject: [PATCH] Fix ICE in Clang when dealing with
> attribute(__no_sanitize_*__)
>
> Summary:
>
> Both syntaxes: __attribute__((no_sanitize_address)) and
> __attribute__((__no_sanitize__address__)) are valid, following
> documentation:
>
>> The attribute identifier (but not scope) can also be specified with a
>> preceding and following __ (double underscore) to avoid interference
>> from a macro with the same name. For instance, gnu::__const__ can be
>> used instead of gnu::const.
>
> This patch is fixing ICE when __const__ syntax is used.
>
> Test Plan:
>
> Added unittests in the patch which cover these cases. After applying
> this patch they don't crash anymore.
> ---
> lib/Sema/SemaDeclAttr.cpp | 28
> +---
> test/SemaCXX/attr-no-sanitize-address.cpp |  2 ++
> test/SemaCXX/attr-no-sanitize-memory.cpp  |  2 ++
> test/SemaCXX/attr-no-sanitize-thread.cpp  |  2 ++
> 4 files changed, 23 insertions(+), 11 deletions(-)

 FWIW, it's usually better to supply svn patches instead of git patches
 (my vcs has troubles applying patches like this).

>
> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
> index 3cf9567..b2f2cff 100644
> --- a/lib/Sema/SemaDeclAttr.cpp
> +++ b/lib/Sema/SemaDeclAttr.cpp
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRange
> AttrRange, Decl *D, Expr *E,
>AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeAttrName(StringRef& AttrName) {

 I would prefer this be called normalizeName since it doesn't just
 normalize attribute names (for instance, this is used to normalize
 attribute arguments as well).

> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Too short attribute name");

 "Name too short" instead.

> +AttrName = AttrName.substr(2, AttrName.size() - 4);

 I prefer: drop_front() and drop_back() instead.

> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>  // This attribute must be applied to a function declaration. The first
>  // argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S, Decl
> *D,
> const AttributeList &AL) {
>
>  IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>  StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeAttrName(ModuleName)) {
>Module = &S.PP.getIdentifierTable().get(ModuleName);
>  }
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, Decl *D,
> const AttributeList &Attr) {
>  IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>  StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeAttrN

r249722 - [CodeGen] Check if the Decl pointer passed is null, and if so, return

2015-10-08 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Oct  8 14:30:57 2015
New Revision: 249722

URL: http://llvm.org/viewvc/llvm-project?rev=249722&view=rev
Log:
[CodeGen] Check if the Decl pointer passed is null, and if so, return
early.

This is needed in a patch I plan to commit later, in which a null Decl
pointer is passed to SetLLVMFunctionAttributesForDefinition.

Relevant discussion is in http://reviews.llvm.org/D13525.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=249722&r1=249721&r2=249722&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Oct  8 14:30:57 2015
@@ -786,6 +786,21 @@ void CodeGenModule::SetLLVMFunctionAttri
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 
+  if (LangOpts.getStackProtector() == LangOptions::SSPOn)
+B.addAttribute(llvm::Attribute::StackProtect);
+  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
+B.addAttribute(llvm::Attribute::StackProtectStrong);
+  else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
+B.addAttribute(llvm::Attribute::StackProtectReq);
+
+  if (!D) {
+F->addAttributes(llvm::AttributeSet::FunctionIndex,
+ llvm::AttributeSet::get(
+ F->getContext(),
+ llvm::AttributeSet::FunctionIndex, B));
+return;
+  }
+
   if (D->hasAttr()) {
 // Naked implies noinline: we should not be inlining such functions.
 B.addAttribute(llvm::Attribute::Naked);
@@ -810,13 +825,6 @@ void CodeGenModule::SetLLVMFunctionAttri
   if (D->hasAttr())
 B.addAttribute(llvm::Attribute::MinSize);
 
-  if (LangOpts.getStackProtector() == LangOptions::SSPOn)
-B.addAttribute(llvm::Attribute::StackProtect);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
-B.addAttribute(llvm::Attribute::StackProtectStrong);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
-B.addAttribute(llvm::Attribute::StackProtectReq);
-
   F->addAttributes(llvm::AttributeSet::FunctionIndex,
llvm::AttributeSet::get(
F->getContext(), llvm::AttributeSet::FunctionIndex, B));


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


Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/cert/SetLongJmpCheck.cpp:31
@@ +30,3 @@
+public:
+  explicit SetJmpMacroCallbacks(Preprocessor *PP, SetLongJmpCheck &Check)
+  : PP(PP), Check(Check) {}

Why do you pass one as a pointer and one as a reference?


http://reviews.llvm.org/D13567



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


Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 3:47 PM, Samuel Benzaquen  wrote:
> sbenza added inline comments.
>
> 
> Comment at: clang-tidy/cert/SetLongJmpCheck.cpp:31
> @@ +30,3 @@
> +public:
> +  explicit SetJmpMacroCallbacks(Preprocessor *PP, SetLongJmpCheck &Check)
> +  : PP(PP), Check(Check) {}
> 
> Why do you pass one as a pointer and one as a reference?

Bad copy-pasta. I don't even need PP. Good catch! I will remove that.

~Aaron

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


Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 36890.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Corrected a simple copy-paste error.


http://reviews.llvm.org/D13567

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/SetLongJmpCheck.cpp
  clang-tidy/cert/SetLongJmpCheck.h
  docs/clang-tidy/checks/cert-setlongjmp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-setlongjmp.cpp

Index: test/clang-tidy/cert-setlongjmp.cpp
===
--- test/clang-tidy/cert-setlongjmp.cpp
+++ test/clang-tidy/cert-setlongjmp.cpp
@@ -0,0 +1,26 @@
+// RUN: %python %S/check_clang_tidy.py %s cert-err52-cpp %t -- -std=c++11
+
+typedef void *jmp_buf;
+extern int __setjmpimpl(jmp_buf);
+#define setjmp(x) __setjmpimpl(x)
+[[noreturn]] extern void longjmp(jmp_buf, int);
+
+namespace std {
+using ::jmp_buf;
+using ::longjmp;
+}
+
+static jmp_buf env;
+void g() {
+  std::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead [cert-err52-cpp]
+  ::longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+  longjmp(env, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call 'longjmp'; consider using exception handling instead
+}
+
+void f() {
+  (void)setjmp(env);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not call 'setjmp'; consider using exception handling instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::
+   cert-setlongjmp
cert-variadic-function-def
cppcoreguidelines-pro-type-const-cast
cppcoreguidelines-pro-type-reinterpret-cast
Index: docs/clang-tidy/checks/cert-setlongjmp.rst
===
--- docs/clang-tidy/checks/cert-setlongjmp.rst
+++ docs/clang-tidy/checks/cert-setlongjmp.rst
@@ -0,0 +1,11 @@
+cert-err52-cpp
+==
+
+The C standard library facilities setjmp() and longjmp() can be used to
+simulate throwing and catching exceptions. However, these facilities bypass
+automatic resource management and can result in undefined behavior, commonly
+including resource leaks, and denial-of-service attacks.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`ERR52-CPP. Do not use setjmp() or longjmp()
+`_.
Index: clang-tidy/cert/SetLongJmpCheck.h
===
--- clang-tidy/cert/SetLongJmpCheck.h
+++ clang-tidy/cert/SetLongJmpCheck.h
@@ -0,0 +1,37 @@
+//===--- SetLongJmpCheck.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_SETLONGJMPCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Guards against use of setjmp/longjmp in C++ code
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-setlongjmp.html
+class SetLongJmpCheck : public ClangTidyCheck {
+public:
+  SetLongJmpCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void registerPPCallbacks(CompilerInstance &Compiler) override;
+
+  static const char DiagWording[];
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SETLONGJMPCHECK_H
+
Index: clang-tidy/cert/SetLongJmpCheck.cpp
===
--- clang-tidy/cert/SetLongJmpCheck.cpp
+++ clang-tidy/cert/SetLongJmpCheck.cpp
@@ -0,0 +1,77 @@
+//===--- SetLongJmpCheck.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 "SetLongJmpCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace 

Re: [PATCH] D13567: [PATCH] Add checker discouraging use of setjmp/longjmp in C++

2015-10-08 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the fast turn-around! I've commit in r249727.

~Aaron


http://reviews.llvm.org/D13567



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


[clang-tools-extra] r249727 - Adding a checker (cert-err52-cpp) that detects use of setjmp or longjmp in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/con

2015-10-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Oct  8 14:54:43 2015
New Revision: 249727

URL: http://llvm.org/viewvc/llvm-project?rev=249727&view=rev
Log:
Adding a checker (cert-err52-cpp) that detects use of setjmp or longjmp in C++ 
code. Corresponds to the CERT C++ secure coding rule: 
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834

Added:
clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-setlongjmp.rst
clang-tools-extra/trunk/test/clang-tidy/cert-setlongjmp.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=249727&r1=249726&r2=249727&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Thu Oct  8 
14:54:43 2015
@@ -15,6 +15,7 @@
 #include "../misc/NewDeleteOverloadsCheck.h"
 #include "../misc/NonCopyableObjects.h"
 #include "../misc/StaticAssertCheck.h"
+#include "SetLongJmpCheck.h"
 #include "VariadicFunctionDefCheck.h"
 
 namespace clang {
@@ -35,6 +36,9 @@ public:
 // OOP
 CheckFactories.registerCheck(
 "cert-oop11-cpp");
+// ERR
+CheckFactories.registerCheck(
+"cert-err52-cpp");
 
 // C checkers
 // DCL

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=249727&r1=249726&r2=249727&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Thu Oct  8 14:54:43 
2015
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCERTModule
   CERTTidyModule.cpp
+  SetLongJmpCheck.cpp
   VariadicFunctionDefCheck.cpp
 
   LINK_LIBS

Added: clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp?rev=249727&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/SetLongJmpCheck.cpp Thu Oct  8 
14:54:43 2015
@@ -0,0 +1,77 @@
+//===--- SetLongJmpCheck.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 "SetLongJmpCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+const char SetLongJmpCheck::DiagWording[] =
+"do not call %0; consider using exception handling instead";
+
+namespace {
+class SetJmpMacroCallbacks : public PPCallbacks {
+  SetLongJmpCheck &Check;
+
+public:
+  explicit SetJmpMacroCallbacks(SetLongJmpCheck &Check) : Check(Check) {}
+
+  void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
+SourceRange Range, const MacroArgs *Args) override {
+const auto *II = MacroNameTok.getIdentifierInfo();
+if (!II)
+  return;
+
+if (II->getName() == "setjmp")
+  Check.diag(Range.getBegin(), Check.DiagWording) << II;
+  }
+};
+} // namespace
+
+void SetLongJmpCheck::registerPPCallbacks(CompilerInstance &Compiler) {
+  // This checker only applies to C++, where exception handling is a superior
+  // solution to setjmp/longjmp calls.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // Per [headers]p5, setjmp must be exposed as a macro instead of a function,
+  // despite the allowance in C for setjmp to also be an extern function.
+  Compiler.getPreprocessor().addPPCallbacks(
+  llvm::make_unique(*this));
+}
+
+void SetLongJmpCheck::registerMatchers(MatchFinder *Finder) {
+  // This checker only applies to C++, where exception handling is a superior
+  // solution to setjmp/longjmp calls.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // In case there is an implementation that happens to define setjmp as a
+  // function instead of a macro, this will also catch use of it. However, we
+  // are primarily searching for 

r249733 - Handle sse turning on mmx, but no -mmx not turning off SSE.

2015-10-08 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Oct  8 15:10:18 2015
New Revision: 249733

URL: http://llvm.org/viewvc/llvm-project?rev=249733&view=rev
Log:
Handle sse turning on mmx, but no -mmx not turning off SSE.

Rationale :

// sse3
__m128d test_mm_addsub_pd(__m128d A, __m128d B) {
  return _mm_addsub_pd(A, B);
}

// mmx
void shift(__m64 a, __m64 b, int c) {
  _mm_slli_pi16(a, c);
  _mm_slli_pi32(a, c);
  _mm_slli_si64(a, c);
  _mm_srli_pi16(a, c);
  _mm_srli_pi32(a, c);
  _mm_srli_si64(a, c);
  _mm_srai_pi16(a, c);
  _mm_srai_pi32(a, c);
}

clang -msse3 -mno-mmx file.c -c

For this code we should be able to explicitly turn off MMX
without affecting the compilation of the SSE3 function and then
diagnose and error on compiling the MMX function.

This is a preparatory patch to the actual diagnosis code which is
coming in a future patch. This sets us up to have the correct information
where we need it and verifies that it's being emitted for the backend
to handle.

Added:
cfe/trunk/test/CodeGen/attr-target-x86-mmx.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249733&r1=249732&r2=249733&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 15:10:18 2015
@@ -2725,6 +2725,14 @@ bool X86TargetInfo::initFeatureMap(
   FeaturesVec.end())
 Features["prfchw"] = true;
 
+  // Additionally, if SSE is enabled and mmx is not explicitly disabled,
+  // then enable MMX.
+  I = Features.find("sse");
+  if (I != Features.end() && I->getValue() == true &&
+  std::find(FeaturesVec.begin(), FeaturesVec.end(), "-mmx") ==
+  FeaturesVec.end())
+Features["mmx"] = true;
+
   return true;
 }
 
@@ -3004,17 +3012,6 @@ bool X86TargetInfo::handleTargetFeatures
 return false;
   }
 
-  // Don't tell the backend if we're turning off mmx; it will end up disabling
-  // SSE, which we don't want.
-  // Additionally, if SSE is enabled and mmx is not explicitly disabled,
-  // then enable MMX.
-  std::vector::iterator it;
-  it = std::find(Features.begin(), Features.end(), "-mmx");
-  if (it != Features.end())
-Features.erase(it);
-  else if (SSELevel > NoSSE)
-MMX3DNowLevel = std::max(MMX3DNowLevel, MMX);
-
   SimdDefaultAlign =
   hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
   return true;

Added: cfe/trunk/test/CodeGen/attr-target-x86-mmx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86-mmx.c?rev=249733&view=auto
==
--- cfe/trunk/test/CodeGen/attr-target-x86-mmx.c (added)
+++ cfe/trunk/test/CodeGen/attr-target-x86-mmx.c Thu Oct  8 15:10:18 2015
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// Picking a cpu that doesn't have mmx or sse by default so we can enable it 
later.
+
+#define __MM_MALLOC_H
+
+#include 
+
+// Verify that when we turn on sse that we also turn on mmx.
+void __attribute__((target("sse"))) shift(__m64 a, __m64 b, int c) {
+  _mm_slli_pi16(a, c);
+  _mm_slli_pi32(a, c);
+  _mm_slli_si64(a, c);
+
+  _mm_srli_pi16(a, c);
+  _mm_srli_pi32(a, c);
+  _mm_srli_si64(a, c);
+
+  _mm_srai_pi16(a, c);
+  _mm_srai_pi32(a, c);
+}
+
+// CHECK: "target-features"="+mmx,+sse"

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=249733&r1=249732&r2=249733&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Thu Oct  8 15:10:18 2015
@@ -16,6 +16,8 @@ int bar(int a) { return baz(a) + foo(a);
 int __attribute__((target("avx,  sse4.2,  arch=   ivybridge"))) 
qux(int a) { return 4; }
 int __attribute__((target("no-aes, arch=ivybridge"))) qax(int a) { return 4; }
 
+int __attribute__((target("no-mmx"))) qq(int a) { return 40; }
+
 // Check that we emit the additional subtarget and cpu features for foo and 
not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
@@ -28,8 +30,10 @@ int __attribute__((target("no-aes, arch=
 // CHECK: bar{{.*}} #0
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-featur

r249732 - Migrate most feature map inclusion to initFeatureMap for the x86 target so

2015-10-08 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Oct  8 15:10:14 2015
New Revision: 249732

URL: http://llvm.org/viewvc/llvm-project?rev=249732&view=rev
Log:
Migrate most feature map inclusion to initFeatureMap for the x86 target so
that we can build up an accurate set of features rather than relying on
TargetInfo initialization via handleTargetFeatures to munge the list
of features.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249732&r1=249731&r2=249732&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 15:10:14 2015
@@ -2705,7 +2705,27 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "cx16", true);
 break;
   }
-  return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+  if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec))
+return false;
+
+  // Can't do this earlier because we need to be able to explicitly enable
+  // or disable these features and the things that they depend upon.
+
+  // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
+  auto I = Features.find("sse4.2");
+  if (I != Features.end() && I->getValue() == true &&
+  std::find(FeaturesVec.begin(), FeaturesVec.end(), "-popcnt") ==
+  FeaturesVec.end())
+Features["popcnt"] = true;
+
+  // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
+  I = Features.find("3dnow");
+  if (I != Features.end() && I->getValue() == true &&
+  std::find(FeaturesVec.begin(), FeaturesVec.end(), "-prfchw") ==
+  FeaturesVec.end())
+Features["prfchw"] = true;
+
+  return true;
 }
 
 void X86TargetInfo::setSSELevel(llvm::StringMap &Features,
@@ -2974,22 +2994,6 @@ bool X86TargetInfo::handleTargetFeatures
 XOPLevel = std::max(XOPLevel, XLevel);
   }
 
-  // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
-  // Can't do this earlier because we need to be able to explicitly enable
-  // popcnt and still disable sse4.2.
-  if (!HasPOPCNT && SSELevel >= SSE42 &&
-  std::find(Features.begin(), Features.end(), "-popcnt") == 
Features.end()){
-HasPOPCNT = true;
-Features.push_back("+popcnt");
-  }
-
-  // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
-  if (!HasPRFCHW && MMX3DNowLevel >= AMD3DNow &&
-  std::find(Features.begin(), Features.end(), "-prfchw") == 
Features.end()){
-HasPRFCHW = true;
-Features.push_back("+prfchw");
-  }
-
   // LLVM doesn't have a separate switch for fpmath, so only accept it if it
   // matches the selected sse level.
   if (FPMath == FP_SSE && SSELevel < SSE1) {

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=249732&r1=249731&r2=249732&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Thu Oct  8 15:10:14 2015
@@ -29,7 +29,7 @@ int __attribute__((target("no-aes, arch=
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
 // CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+pclmul,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,-aes"
+// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
+// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,-aes"


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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores. Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>  AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
>  }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");
>

This assert will fire on the strings __, ___, and , which are valid in
some of the below cases.


> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>// This attribute must be applied to a function declaration. The first
>// argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>
>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeName(ModuleName)) {
>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>}
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeName(Format)) {
>  // If we've modified the string name, we need a new identifier for it.
>  II = &S.Context.Idents.get(Format);
>}
> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>StringRef Str = Name->getName();
>
> -  // Normalize the attribute name, __foo__ becomes foo.
> -  if (Str.startswith("__") && Str.endswith("__"))
> -Str = Str.substr(2, Str.size() - 4);
> +  normalizeName(Str);
>
>unsigned DestWidth = 0;
>bool IntegerMode = true;
> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
>
>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>   const AttributeList &Attr) {
> +  StringRef AttrName = Attr.getName()->getName();
> +  normalizeName(AttrName);
>std::string SanitizerName =
> -  llvm::StringSwitch(Attr.getName()->getName())
> +  llvm::StringSwitch(AttrName)
>.Case("no_address_safety_analysis", "address")
>.Case("no_sanitize_address", "address")
>.Case("no_sanitize_thread", "thread")
>

Is there any way we could use the spelling list index in this case rather
than repeating the attribute names and __-stripping here?

Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp?rev=249721&r1=249720&r2=249721&view=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp (original)
> +++ cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp Thu Oct  8
> 14:24:08 2015
> @@ -5,12 +5,14 @@
>  #if !__has_attribute(no_sanitize_address)
>  #error "Should support no_sanitize_address"
>  #endif
> -
> -void noanal_fun() NO_SANITIZE_ADDRESS;
> -
> -void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
> -  // expected-error {{'no_sanitize_address' attribute takes no arguments}}
> -
> +
> +void noanal_fun() NO_SANITIZE_ADDRESS;
> +
> +void noanal_fun_alt() __attribute__((__no_sanitize_address__));
> +
> +void noanal_fun_args() __attribute__((

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 6:27 AM, Marshall Clow  wrote:

> On Wed, Oct 7, 2015 at 2:38 PM, Richard Smith 
> wrote:
>
>> Marshall: ping, does the below satisfy your concerns about the direction
>> here?
>>
>
> No, not really, because I'm worried about behavior changes with this
> approach.
>
> #include 
>isdigit(c);
>
> will call different code before and after this patch.
> Before the patch, it will use the macro version.
>

That was non-conforming behaviour, per [headers]/6:

  "Names that are defined as functions in C shall be defined as functions
in the C++ standard library. [Footnote: This disallows the practice,
allowed in C, of providing a masking macro in addition to the function
prototype.]"

After, it will use the built-in function.
>
> However, since other standard libraries use this approach, this is
> probably a baseless concern.
>
> Assuming that my concerns are unfounded, the first six patches
> (remove-macros, nullptr, ctype, errno and float) look fine to me.
>
> Working on the rest.
>
> -- Marshall
>
>
>
>> On Wed, Sep 16, 2015 at 2:04 PM, Richard Smith 
>> wrote:
>>
>>> On Mon, Sep 14, 2015 at 7:07 AM, Marshall Clow 
>>> wrote:
>>>
 mclow.lists added a comment.

 I have two concerns about this patch (w/o commenting on the actual
 code).

 1. Until very recently, I was under the impression that C libraries
 _either_ defined a macro, or had a function. I was quite surprised to find
 that glibc did both.
>>>
>>>
>>> Yes, this is required by the C standard. C11 7.1.4/1 says:
>>>
>>> "Any function declared in a header may be additionally implemented as a
>>> function-like macro defined in the header [...]. Any macro definition of a
>>> function can be suppressed locally by enclosing the name of the function in
>>> parentheses, because the name is then not followed by the left parenthesis
>>> that indicates expansion of a macro function name. For the same syntactic
>>> reason, it is permitted to take the address of a library function even if
>>> it is also defined as a macro. [Footnote: This means that an implementation
>>> shall provide an actual function for each library function, even if it also
>>> provides a macro for that function.]"
>>>
>>> Have you checked other C libraries (Apple, FreeBSD, Android, Windows) to
 see if they also define both?
>>>
>>>
>>> No, but libstdc++ does the same #undef thing, so any platform it
>>> supports must have a non-broken C standard library.
>>>
>>>
 2. This adds a lot of header files. Each header file slows down
 compilation, and standard library header files get included *a lot*. We may
 not be able to avoid this, but we should think about the costs here.
>>>
>>>
>>> I created a .cpp file that includes all of the <*.h> headers and does
>>> nothing else (which should maximize the performance difference), and built
>>> it with and without this change. I could not measure any difference (the
>>> average compile time with this change was slightly lower, but that is
>>> almost certainly noise).
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith  wrote:
> On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Thu Oct  8 14:24:08 2015
>> New Revision: 249721
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
>> Log:
>> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
>> GNU-style formatting that involves prefix and suffix underscores. Cleans up
>> other usages of similar functionality.
>>
>> Patch by Adrian Zgorzalek!
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>>  AssumeAlignedAttr(AttrRange, Context, E, OE,
>> SpellingListIndex));
>>  }
>>
>> +/// Normalize the attribute, __foo__ becomes foo.
>> +/// Returns true if normalization was applied.
>> +static bool normalizeName(StringRef &AttrName) {
>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> +assert(AttrName.size() > 4 && "Name too short");
>
>
> This assert will fire on the strings __, ___, and , which are valid in
> some of the below cases.

That assert won't fire on anything but  because it's &&, not ||. I
don't think these names were intended to be valid in their uses.
However, you are correct that this will trigger assertions instead of
diagnostics. Adrian, can you investigate?

>
>>
>> +AttrName = AttrName.drop_front(2).drop_back(2);
>> +return true;
>> +  }
>> +  return false;
>> +}
>> +
>>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>> &AL) {
>>// This attribute must be applied to a function declaration. The first
>>// argument to the attribute must be an identifier, the name of the
>> resource,
>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>>
>>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>>StringRef ModuleName = Module->getName();
>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> -  ModuleName.size() > 4) {
>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>> +  if (normalizeName(ModuleName)) {
>>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>>}
>>
>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>StringRef Format = II->getName();
>>
>> -  // Normalize the argument, __foo__ becomes foo.
>> -  if (Format.startswith("__") && Format.endswith("__")) {
>> -Format = Format.substr(2, Format.size() - 4);
>> +  if (normalizeName(Format)) {
>>  // If we've modified the string name, we need a new identifier for
>> it.
>>  II = &S.Context.Idents.get(Format);
>>}
>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>StringRef Str = Name->getName();
>>
>> -  // Normalize the attribute name, __foo__ becomes foo.
>> -  if (Str.startswith("__") && Str.endswith("__"))
>> -Str = Str.substr(2, Str.size() - 4);
>> +  normalizeName(Str);
>>
>>unsigned DestWidth = 0;
>>bool IntegerMode = true;
>> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
>>
>>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>>   const AttributeList &Attr) {
>> +  StringRef AttrName = Attr.getName()->getName();
>> +  normalizeName(AttrName);
>>std::string SanitizerName =
>> -  llvm::StringSwitch(Attr.getName()->getName())
>> +  llvm::StringSwitch(AttrName)
>>.Case("no_address_safety_analysis", "address")
>>.Case("no_sanitize_address", "address")
>>.Case("no_sanitize_thread", "thread")
>
>
> Is there any way we could use the spelling list index in this case rather
> than repeating the attribute names and __-stripping here?

The spelling list index isn't exposed in a meaningful way (and I think
that would be an abuse of it; I want to someday remove that
implementation detail to something far more private).

I was hoping there would be a way to use the semantic spelling, but
the issue is that this particular attribute doesn't have semantic
spellings. The NoSanitizeSpecificAttr would have one, but it has no
AST node to hang those off of. Since we explicitly document that we do
not want any additional names added to this list (see Attr.td line
1500), I 

r249735 - [CodeGen] [CodeGen] Attach function attributes to functions created in

2015-10-08 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Oct  8 15:26:34 2015
New Revision: 249735

URL: http://llvm.org/viewvc/llvm-project?rev=249735&view=rev
Log:
[CodeGen] [CodeGen] Attach function attributes to functions created in
CGBlocks.cpp.

This commit fixes a bug in clang's code-gen where it creates the
following functions but doesn't attach function attributes to them:

__copy_helper_block_
__destroy_helper_block_
__Block_byref_object_copy_
__Block_byref_object_dispose_

rdar://problem/20828324

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenObjC/arc-blocks.m

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=249735&r1=249734&r2=249735&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Oct  8 15:26:34 2015
@@ -1345,6 +1345,9 @@ CodeGenFunction::GenerateCopyHelperFunct
   nullptr, SC_Static,
   false,
   false);
+
+  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
   // Create a scope with an artificial location for the body of this function.
@@ -1516,6 +1519,9 @@ CodeGenFunction::GenerateDestroyHelperFu
   SourceLocation(), II, C.VoidTy,
   nullptr, SC_Static,
   false, false);
+
+  CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   // Create a scope with an artificial location for the body of this function.
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(FD, C.VoidTy, Fn, FI, args);
@@ -1798,6 +1804,8 @@ generateByrefCopyHelper(CodeGenFunction
   SC_Static,
   false, false);
 
+  CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   CGF.StartFunction(FD, R, Fn, FI, args);
 
   if (generator.needsCopy()) {
@@ -1869,6 +1877,9 @@ generateByrefDisposeHelper(CodeGenFuncti
   SourceLocation(), II, R, nullptr,
   SC_Static,
   false, false);
+
+  CGF.CGM.SetInternalFunctionAttributes(nullptr, Fn, FI);
+
   CGF.StartFunction(FD, R, Fn, FI, args);
 
   if (generator.needsDispose()) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=249735&r1=249734&r2=249735&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Oct  8 15:26:34 2015
@@ -867,12 +867,12 @@ void CodeGenModule::SetLLVMFunctionAttri
 
 void CodeGenModule::SetCommonAttributes(const Decl *D,
 llvm::GlobalValue *GV) {
-  if (const auto *ND = dyn_cast(D))
+  if (const auto *ND = dyn_cast_or_null(D))
 setGlobalVisibility(GV, ND);
   else
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 
-  if (D->hasAttr())
+  if (D && D->hasAttr())
 addUsedGlobal(GV);
 }
 
@@ -890,8 +890,9 @@ void CodeGenModule::setNonAliasAttribute
   llvm::GlobalObject *GO) {
   SetCommonAttributes(D, GO);
 
-  if (const SectionAttr *SA = D->getAttr())
-GO->setSection(SA->getName());
+  if (D)
+if (const SectionAttr *SA = D->getAttr())
+  GO->setSection(SA->getName());
 
   getTargetCodeGenInfo().setTargetAttributes(D, GO, *this);
 }

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=249735&r1=249734&r2=249735&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Oct  8 15:26:34 2015
@@ -1528,7 +1528,7 @@ bool X86_32TargetCodeGenInfo::isStructRe
 void X86_32TargetCodeGenInfo::setTargetAttributes(const Decl *D,
   llvm::GlobalValue *GV,
 CodeGen::CodeGenModule &CGM) const 
{
-  if (const FunctionDecl *FD = dyn_cast(D)) {
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
 if (FD->hasAttr()) {
   // Get the LLVM function.
   llvm::Function *Fn = cast(GV);
@@ -1898,7 +1898,7 @@ public:
 static void addStackProbeSizeTargetAttribute(const Decl *D,
  llvm::GlobalValue *GV,
   

Re: [PATCH] D13525: [CodeGen] Attach function attributes to functions created in CGBlocks.cpp.

2015-10-08 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249735: [CodeGen] [CodeGen] Attach function attributes to 
functions created in (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D13525?vs=36886&id=36891#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13525

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenObjC/arc-blocks.m

Index: cfe/trunk/test/CodeGenObjC/arc-blocks.m
===
--- cfe/trunk/test/CodeGenObjC/arc-blocks.m
+++ cfe/trunk/test/CodeGenObjC/arc-blocks.m
@@ -43,7 +43,7 @@
   extern void test2_helper(id (^)(void));
   test2_helper(^{ return x; });
 
-// CHECK-LABEL:define internal void @__copy_helper_block_
+// CHECK-LABEL:define internal void @__copy_helper_block_(i8*, i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[SRC:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8**
@@ -53,7 +53,7 @@
 // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) [[NUW]]
 // CHECK-NEXT: ret void
 
-// CHECK-LABEL:define internal void @__destroy_helper_block_
+// CHECK-LABEL:define internal void @__destroy_helper_block_(i8*) #{{[0-9]+}} {
 // CHECK:  [[T0:%.*]] = load i8*, i8**
 // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]*
 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[T1]], i32 0, i32 5
@@ -134,16 +134,16 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[T1]]
   // CHECK-NEXT: store i8* [[T2]], i8** [[T0]]
   // CHECK-NEXT: store i8* null, i8** [[T1]]
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]]
   // CHECK-NEXT: call void @objc_release(i8* [[T1]])
@@ -155,10 +155,10 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T0]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
 }
 
@@ -221,27 +221,27 @@
   // CHECK-NEXT: call void @llvm.lifetime.end(i64 48, i8* [[VARPTR2]])
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_copy_
+  // CHECK-LABEL:define internal void @__Block_byref_object_copy_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: load i8*, i8**
   // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]])
 
-  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_
+  // CHECK-LABEL:define internal void @__Block_byref_object_dispose_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // CHECK:  [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6
   // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
 
   // CHECK-LABEL:define internal void @__test6_block_invoke
   // CHECK:  [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
   // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
   // CHECK-NEXT: ret void
 
-  // CHECK-LABEL:define internal void @__copy_helper_block_
+  // CHECK-LABEL:define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} {
   // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
   // CHECK:  call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
 
-  // CHECK-LABEL:define internal void @__destroy_helper_block_
+  // CHECK-LABEL:define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} {
   // 0x8 - F

Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 7:23 AM, Marshall Clow  wrote:

> On Tue, Oct 6, 2015 at 3:36 PM, Richard Smith 
> wrote:
>
>> Split  out of . This is a big change, but the same pattern
>> as the prior ones.
>>
>> In this patch, you replicate the #ifdef XXX, __libcpp_XXX, #undef XXX
> dance for all the isXXX functions. Is that because they're not required to
> be actual functions in a C library?
>

Yes. Per C11 7.12.3, the following are defined as type-generic macros that
take any real floating-point type:

  fpclassify, isfinite, isinf, isnan, isnormal, signbit

Per C11 7.12.14, the following are defined as type-generic macros that take
any pair of real floating-point types:

  isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered

Per [c.math]p10, we are required to remove those macros and replace them
with a set of overloaded functions. For those cases (and *only* those
cases), we define a function template to capture the contents of the macro,
then undefine the macro.

Note that libc++'s behavior here is non-conforming (both before and after
this change) because it's required to provide a specific set of overloads,
but instead only provides a template. This patch series neither improves
nor regresses libc++'s conformance in that area.


> Other than that Q, LGTM. Like the extended tests.
>
> -- Marshall
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r249737 - Factor definition of std::nullptr_t out of into a header that can also be used by .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:34:11 2015
New Revision: 249737

URL: http://llvm.org/viewvc/llvm-project?rev=249737&view=rev
Log:
Factor definition of std::nullptr_t out of  into a header that can 
also be used by .

Added:
libcxx/trunk/include/__nullptr
  - copied, changed from r249736, libcxx/trunk/include/cstddef
Modified:
libcxx/trunk/include/cstddef

Copied: libcxx/trunk/include/__nullptr (from r249736, 
libcxx/trunk/include/cstddef)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__nullptr?p2=libcxx/trunk/include/__nullptr&p1=libcxx/trunk/include/cstddef&r1=249736&r2=249737&rev=249737&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/__nullptr Thu Oct  8 15:34:11 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cstddef 
--===//
+//===--- __nullptr 
===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,53 +8,19 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CSTDDEF
-#define _LIBCPP_CSTDDEF
-
-/*
-cstddef synopsis
-
-Macros:
-
-offsetof(type,member-designator)
-NULL
-
-namespace std
-{
-
-Types:
-
-ptrdiff_t
-size_t
-max_align_t
-nullptr_t
-
-}  // std
-
-*/
+#ifndef _LIBCPP_NULLPTR
+#define _LIBCPP_NULLPTR
 
 #include <__config>
 
-#include 
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-using ::ptrdiff_t;
-using ::size_t;
-
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
-// Re-use the compiler's  max_align_t where possible.
-using ::max_align_t;
-#else
-typedef long double max_align_t;
-#endif
-
 #ifdef _LIBCPP_HAS_NO_NULLPTR
 
+_LIBCPP_BEGIN_NAMESPACE_STD
+
 struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
 {
 void* __lx;
@@ -86,11 +52,9 @@ inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CON
 
 #define nullptr _VSTD::__get_nullptr_t()
 
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 _LIBCPP_END_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_NULLPTR
+#else  // _LIBCPP_HAS_NO_NULLPTR
 
 namespace std
 {
@@ -99,4 +63,4 @@ namespace std
 
 #endif  // _LIBCPP_HAS_NO_NULLPTR
 
-#endif  // _LIBCPP_CSTDDEF
+#endif  // _LIBCPP_NULLPTR

Modified: libcxx/trunk/include/cstddef
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=249737&r1=249736&r2=249737&view=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Thu Oct  8 15:34:11 2015
@@ -34,6 +34,7 @@ Types:
 */
 
 #include <__config>
+#include <__nullptr>
 
 #include 
 
@@ -53,50 +54,6 @@ using ::max_align_t;
 typedef long double max_align_t;
 #endif
 
-#ifdef _LIBCPP_HAS_NO_NULLPTR
-
-struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
-{
-void* __lx;
-
-struct __nat {int __for_bool_;};
-
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {}
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) 
{}
-
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const 
{return 0;}
-
-template 
-_LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR
-operator _Tp* () const {return 0;}
-
-template 
-_LIBCPP_ALWAYS_INLINE
-operator _Tp _Up::* () const {return 0;}
-
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, 
nullptr_t) {return true;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, 
nullptr_t) {return true;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, 
nullptr_t) {return true;}
-};
-
-inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() 
{return nullptr_t(0);}
-
-#define nullptr _VSTD::__get_nullptr_t()
-
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 _LIBCPP_END_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_NULLPTR
-
-namespace std
-{
-typedef decltype(nullptr) nullptr_t;
-}
-
-#endif  // _LIBCPP_HAS_NO_NULLPTR
-
 #endif  // _LIBCPP_CSTDDEF


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


[libcxx] r249738 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:36:30 2015
New Revision: 249738

URL: http://llvm.org/viewvc/llvm-project?rev=249738&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/ctype.h
  - copied, changed from r249736, libcxx/trunk/include/cctype
Modified:
libcxx/trunk/include/cctype
libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp

Modified: libcxx/trunk/include/cctype
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cctype?rev=249738&r1=249737&r2=249738&view=diff
==
--- libcxx/trunk/include/cctype (original)
+++ libcxx/trunk/include/cctype Thu Oct  8 15:36:30 2015
@@ -37,10 +37,6 @@ int toupper(int c);
 
 #include <__config>
 #include 
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/support.h"
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -48,33 +44,19 @@ int toupper(int c);
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#undef isalnum
 using ::isalnum;
-#undef isalpha
 using ::isalpha;
-#undef isblank
 using ::isblank;
-#undef iscntrl
 using ::iscntrl;
-#undef isdigit
 using ::isdigit;
-#undef isgraph
 using ::isgraph;
-#undef islower
 using ::islower;
-#undef isprint
 using ::isprint;
-#undef ispunct
 using ::ispunct;
-#undef isspace
 using ::isspace;
-#undef isupper
 using ::isupper;
-#undef isxdigit
 using ::isxdigit;
-#undef tolower
 using ::tolower;
-#undef toupper
 using ::toupper;
 
 _LIBCPP_END_NAMESPACE_STD

Copied: libcxx/trunk/include/ctype.h (from r249736, libcxx/trunk/include/cctype)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ctype.h?p2=libcxx/trunk/include/ctype.h&p1=libcxx/trunk/include/cctype&r1=249736&r2=249738&rev=249738&view=diff
==
--- libcxx/trunk/include/cctype (original)
+++ libcxx/trunk/include/ctype.h Thu Oct  8 15:36:30 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//=== cctype 
--===//
+//=== ctype.h 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,14 +8,11 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CCTYPE
-#define _LIBCPP_CCTYPE
+#ifndef _LIBCPP_CTYPE_H
+#define _LIBCPP_CTYPE_H
 
 /*
-cctype synopsis
-
-namespace std
-{
+ctype.h synopsis
 
 int isalnum(int c);
 int isalpha(int c);
@@ -31,52 +28,41 @@ int isupper(int c);
 int isxdigit(int c);
 int tolower(int c);
 int toupper(int c);
-
-}  // std
 */
 
 #include <__config>
-#include 
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/support.h"
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#ifdef __cplusplus
+
+#if defined(_LIBCPP_MSVCRT)
+// We support including .h headers inside 'extern "C"' contexts, so switch
+// back to C++ linkage before including these C++ headers.
+extern "C++" {
+  #include "support/win32/support.h"
+  #include "support/win32/locale_win32.h"
+}
+#endif // _LIBCPP_MSVCRT
 
 #undef isalnum
-using ::isalnum;
 #undef isalpha
-using ::isalpha;
 #undef isblank
-using ::isblank;
 #undef iscntrl
-using ::iscntrl;
 #undef isdigit
-using ::isdigit;
 #undef isgraph
-using ::isgraph;
 #undef islower
-using ::islower;
 #undef isprint
-using ::isprint;
 #undef ispunct
-using ::ispunct;
 #undef isspace
-using ::isspace;
 #undef isupper
-using ::isupper;
 #undef isxdigit
-using ::isxdigit;
 #undef tolower
-using ::tolower;
 #undef toupper
-using ::toupper;
 
-_LIBCPP_END_NAMESPACE_STD
+#endif
 
-#endif  // _LIBCPP_CCTYPE
+#endif  // _LIBCPP_CTYPE_H

Modified: libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp?rev=249738&r1=249737&r2=249738&view=diff
==
--- libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp Thu Oct  8 15:36:30 
2015
@@ -86,18 +86,18 @@ int main()
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 
-assert(isalnum('a'));
-assert(isalpha('a'));
-assert(isblank(' '));
-assert(!iscntrl(' '));
-assert(!isdigit('a'));
-assert(isgraph('a'));
-assert(islower('a'));
-assert(isprint('a'));
-assert(!ispunct('a'));
-assert(!isspace('a'));
-assert(!isupper('a'));
-assert(isxdigit('a'));
-assert(tolower('A') == 'a');
-assert(toupper('a') == 'A');
+assert(std::isalnum('a'));
+assert(std::isalpha('a'));
+assert(std::isblank(' '));
+assert(!std::iscntrl(' '));
+assert(!std::isdig

[libcxx] r249740 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:37:44 2015
New Revision: 249740

URL: http://llvm.org/viewvc/llvm-project?rev=249740&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/float.h
  - copied, changed from r249736, libcxx/trunk/include/cfloat
Modified:
libcxx/trunk/include/cfloat

Modified: libcxx/trunk/include/cfloat
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cfloat?rev=249740&r1=249739&r2=249740&view=diff
==
--- libcxx/trunk/include/cfloat (original)
+++ libcxx/trunk/include/cfloat Thu Oct  8 15:37:44 2015
@@ -67,12 +67,4 @@ Macros:
 #pragma GCC system_header
 #endif
 
-#ifndef FLT_EVAL_METHOD
-#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
-#endif
-
-#ifndef DECIMAL_DIG
-#define DECIMAL_DIG __DECIMAL_DIG__
-#endif
-
 #endif  // _LIBCPP_CFLOAT

Copied: libcxx/trunk/include/float.h (from r249736, libcxx/trunk/include/cfloat)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/float.h?p2=libcxx/trunk/include/float.h&p1=libcxx/trunk/include/cfloat&r1=249736&r2=249740&rev=249740&view=diff
==
--- libcxx/trunk/include/cfloat (original)
+++ libcxx/trunk/include/float.h Thu Oct  8 15:37:44 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cfloat 
---===//
+//===--- float.h 
--===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,11 +8,11 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CFLOAT
-#define _LIBCPP_CFLOAT
+#ifndef _LIBCPP_FLOAT_H
+#define _LIBCPP_FLOAT_H
 
 /*
-cfloat synopsis
+float.h synopsis
 
 Macros:
 
@@ -61,7 +61,7 @@ Macros:
 */
 
 #include <__config>
-#include 
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -75,4 +75,4 @@ Macros:
 #define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
-#endif  // _LIBCPP_CFLOAT
+#endif  // _LIBCPP_FLOAT_H


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


[libcxx] r249739 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:37:11 2015
New Revision: 249739

URL: http://llvm.org/viewvc/llvm-project?rev=249739&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/errno.h
  - copied, changed from r249736, libcxx/trunk/include/cerrno
Modified:
libcxx/trunk/include/cerrno

Modified: libcxx/trunk/include/cerrno
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cerrno?rev=249739&r1=249738&r2=249739&view=diff
==
--- libcxx/trunk/include/cerrno (original)
+++ libcxx/trunk/include/cerrno Thu Oct  8 15:37:11 2015
@@ -30,364 +30,4 @@ Macros:
 #pragma GCC system_header
 #endif
 
-#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
-
-#ifdef ELAST
-
-const int __elast1 = ELAST+1;
-const int __elast2 = ELAST+2;
-
-#else
-
-const int __elast1 = 104;
-const int __elast2 = 105;
-
-#endif
-
-#ifdef ENOTRECOVERABLE
-
-#define EOWNERDEAD __elast1
-
-#ifdef ELAST
-#undef ELAST
-#define ELAST EOWNERDEAD
-#endif
-
-#elif defined(EOWNERDEAD)
-
-#define ENOTRECOVERABLE __elast1
-#ifdef ELAST
-#undef ELAST
-#define ELAST ENOTRECOVERABLE
-#endif
-
-#else  // defined(EOWNERDEAD)
-
-#define EOWNERDEAD __elast1
-#define ENOTRECOVERABLE __elast2
-#ifdef ELAST
-#undef ELAST
-#define ELAST ENOTRECOVERABLE
-#endif
-
-#endif  // defined(EOWNERDEAD)
-
-#endif  // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
-
-//  supply errno values likely to be missing, particularly on Windows
-
-#ifndef EAFNOSUPPORT
-#define EAFNOSUPPORT 9901
-#endif
-
-#ifndef EADDRINUSE
-#define EADDRINUSE 9902
-#endif
-
-#ifndef EADDRNOTAVAIL
-#define EADDRNOTAVAIL 9903
-#endif
-
-#ifndef EISCONN
-#define EISCONN 9904
-#endif
-
-#ifndef EBADMSG
-#define EBADMSG 9905
-#endif
-
-#ifndef ECONNABORTED
-#define ECONNABORTED 9906
-#endif
-
-#ifndef EALREADY
-#define EALREADY 9907
-#endif
-
-#ifndef ECONNREFUSED
-#define ECONNREFUSED 9908
-#endif
-
-#ifndef ECONNRESET
-#define ECONNRESET 9909
-#endif
-
-#ifndef EDESTADDRREQ
-#define EDESTADDRREQ 9910
-#endif
-
-#ifndef EHOSTUNREACH
-#define EHOSTUNREACH 9911
-#endif
-
-#ifndef EIDRM
-#define EIDRM 9912
-#endif
-
-#ifndef EMSGSIZE
-#define EMSGSIZE 9913
-#endif
-
-#ifndef ENETDOWN
-#define ENETDOWN 9914
-#endif
-
-#ifndef ENETRESET
-#define ENETRESET 9915
-#endif
-
-#ifndef ENETUNREACH
-#define ENETUNREACH 9916
-#endif
-
-#ifndef ENOBUFS
-#define ENOBUFS 9917
-#endif
-
-#ifndef ENOLINK
-#define ENOLINK 9918
-#endif
-
-#ifndef ENODATA
-#define ENODATA 9919
-#endif
-
-#ifndef ENOMSG
-#define ENOMSG 9920
-#endif
-
-#ifndef ENOPROTOOPT
-#define ENOPROTOOPT 9921
-#endif
-
-#ifndef ENOSR
-#define ENOSR 9922
-#endif
-
-#ifndef ENOTSOCK
-#define ENOTSOCK 9923
-#endif
-
-#ifndef ENOSTR
-#define ENOSTR 9924
-#endif
-
-#ifndef ENOTCONN
-#define ENOTCONN 9925
-#endif
-
-#ifndef ENOTSUP
-#define ENOTSUP 9926
-#endif
-
-#ifndef ECANCELED
-#define ECANCELED 9927
-#endif
-
-#ifndef EINPROGRESS
-#define EINPROGRESS 9928
-#endif
-
-#ifndef EOPNOTSUPP
-#define EOPNOTSUPP 9929
-#endif
-
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK 9930
-#endif
-
-#ifndef EOWNERDEAD
-#define EOWNERDEAD  9931
-#endif
-
-#ifndef EPROTO
-#define EPROTO 9932
-#endif
-
-#ifndef EPROTONOSUPPORT
-#define EPROTONOSUPPORT 9933
-#endif
-
-#ifndef ENOTRECOVERABLE
-#define ENOTRECOVERABLE 9934
-#endif
-
-#ifndef ETIME
-#define ETIME 9935
-#endif
-
-#ifndef ETXTBSY
-#define ETXTBSY 9936
-#endif
-
-#ifndef ETIMEDOUT
-#define ETIMEDOUT 9938
-#endif
-
-#ifndef ELOOP
-#define ELOOP 9939
-#endif
-
-#ifndef EOVERFLOW
-#define EOVERFLOW 9940
-#endif
-
-#ifndef EPROTOTYPE
-#define EPROTOTYPE 9941
-#endif
-
-#ifndef ENOSYS
-#define ENOSYS 9942
-#endif
-
-#ifndef EINVAL
-#define EINVAL 9943
-#endif
-
-#ifndef ERANGE
-#define ERANGE 9944
-#endif
-
-#ifndef EILSEQ
-#define EILSEQ 9945
-#endif
-
-//  Windows Mobile doesn't appear to define these:
-
-#ifndef E2BIG
-#define E2BIG 9946
-#endif
-
-#ifndef EDOM
-#define EDOM 9947
-#endif
-
-#ifndef EFAULT
-#define EFAULT 9948
-#endif
-
-#ifndef EBADF
-#define EBADF 9949
-#endif
-
-#ifndef EPIPE
-#define EPIPE 9950
-#endif
-
-#ifndef EXDEV
-#define EXDEV 9951
-#endif
-
-#ifndef EBUSY
-#define EBUSY 9952
-#endif
-
-#ifndef ENOTEMPTY
-#define ENOTEMPTY 9953
-#endif
-
-#ifndef ENOEXEC
-#define ENOEXEC 9954
-#endif
-
-#ifndef EEXIST
-#define EEXIST 9955
-#endif
-
-#ifndef EFBIG
-#define EFBIG 9956
-#endif
-
-#ifndef ENAMETOOLONG
-#define ENAMETOOLONG 9957
-#endif
-
-#ifndef ENOTTY
-#define ENOTTY 9958
-#endif
-
-#ifndef EINTR
-#define EINTR 9959
-#endif
-
-#ifndef ESPIPE
-#define ESPIPE 9960
-#endif
-
-#ifndef EIO
-#define EIO 9961
-#endif
-
-#ifndef EISDIR
-#define EISDIR 9962
-#endif
-
-#ifndef ECHILD
-#define ECHILD 9963
-#endif
-
-#ifndef ENOLCK
-#define ENOLCK 9964
-#endif
-
-#ifndef ENOSPC
-#define ENOSPC 9965
-#endif
-
-#ifndef ENXIO
-#define ENXIO 9966
-#endif
-
-#ifndef ENODEV
-#define ENODEV 9967
-#endif
-
-#ifndef ENOENT
-#define ENOENT 9968
-#endif
-
-#ifndef ESRCH
-#define ESRCH 9969
-#endif
-
-#ifndef ENOTDIR
-#def

[libcxx] r249741 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:38:53 2015
New Revision: 249741

URL: http://llvm.org/viewvc/llvm-project?rev=249741&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/inttypes.h
  - copied, changed from r249736, libcxx/trunk/include/cinttypes
Modified:
libcxx/trunk/include/cinttypes
libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp

Modified: libcxx/trunk/include/cinttypes
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cinttypes?rev=249741&r1=249740&r2=249741&view=diff
==
--- libcxx/trunk/include/cinttypes (original)
+++ libcxx/trunk/include/cinttypes Thu Oct  8 15:38:53 2015
@@ -246,10 +246,7 @@ uintmax_t wcstoumax(const wchar_t* restr
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using::imaxdiv_t;
-
-#undef imaxabs
 using::imaxabs;
-#undef imaxdiv
 using::imaxdiv;
 using::strtoimax;
 using::strtoumax;

Copied: libcxx/trunk/include/inttypes.h (from r249736, 
libcxx/trunk/include/cinttypes)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/inttypes.h?p2=libcxx/trunk/include/inttypes.h&p1=libcxx/trunk/include/cinttypes&r1=249736&r2=249741&rev=249741&view=diff
==
--- libcxx/trunk/include/cinttypes (original)
+++ libcxx/trunk/include/inttypes.h Thu Oct  8 15:38:53 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- cinttypes 
===//
+//===--- inttypes.h 
---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,15 +8,15 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CINTTYPES
-#define _LIBCPP_CINTTYPES
+#ifndef _LIBCPP_INTTYPES_H
+#define _LIBCPP_INTTYPES_H
 
 /*
-cinttypes synopsis
+inttypes.h synopsis
 
 This entire header is C99 / C++0X
 
-#include   //  includes 
+#include   //  includes 
 
 Macros:
 
@@ -218,9 +218,6 @@ Macros:
 SCNxMAX
 SCNxPTR
 
-namespace std
-{
-
 Types:
 
 imaxdiv_t
@@ -232,30 +229,22 @@ uintmax_t strtoumax(const char* restrict
 intmax_t  wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, 
int base);
 uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, 
int base);
 
-}  // std
 */
 
 #include <__config>
-#include 
-#include 
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#ifdef __cplusplus
 
-using::imaxdiv_t;
+#include 
 
 #undef imaxabs
-using::imaxabs;
 #undef imaxdiv
-using::imaxdiv;
-using::strtoimax;
-using::strtoumax;
-using::wcstoimax;
-using::wcstoumax;
 
-_LIBCPP_END_NAMESPACE_STD
+#endif
 
-#endif  // _LIBCPP_CINTTYPES
+#endif  // _LIBCPP_INTTYPES_H

Modified: libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp?rev=249741&r1=249740&r2=249741&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/inttypes_h.pass.cpp Thu Oct  8 
15:38:53 2015
@@ -12,6 +12,250 @@
 #include 
 #include 
 
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined

[PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added a reviewer: echristo.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.
Herald added subscribers: srhines, danalbert, tberghammer.

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

Repository:
  rL LLVM

http://reviews.llvm.org/D13572

Files:
  lib/Basic/Targets.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -989,7 +989,7 @@
   CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=1");
 else
   CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=0");
-  } else if (Triple.getEnvironment() == llvm::Triple::Android) {
+  } else if (Triple.isAndroid()) {
 // Enabled A53 errata (835769) workaround by default on android
 CmdArgs.push_back("-backend-option");
 CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=1");
@@ -1022,7 +1022,7 @@
   }
 
   // MIPS64r6 is the default for Android MIPS64 (mips64el-linux-android).
-  if (Triple.getEnvironment() == llvm::Triple::Android)
+  if (Triple.isAndroid())
 DefMips64CPU = "mips64r6";
 
   // MIPS3 is the default for mips64*-unknown-openbsd.
@@ -1527,7 +1527,7 @@
 return "btver2";
 
   // On Android use targets compatible with gcc
-  if (Triple.getEnvironment() == llvm::Triple::Android)
+  if (Triple.isAndroid())
 return Is64Bit ? "x86-64" : "i686";
 
   // Everything else goes to x86-64 in 64-bit mode.
@@ -1824,7 +1824,7 @@
 
   const llvm::Triple::ArchType ArchType = Triple.getArch();
   // Add features to be compatible with gcc for Android.
-  if (Triple.getEnvironment() == llvm::Triple::Android) {
+  if (Triple.isAndroid()) {
 if (ArchType == llvm::Triple::x86_64) {
   Features.push_back("+sse4.2");
   Features.push_back("+popcnt");
@@ -2593,8 +2593,7 @@
   }
 
   // Collect static runtimes.
-  if (Args.hasArg(options::OPT_shared) ||
-  (TC.getTriple().getEnvironment() == llvm::Triple::Android)) {
+  if (Args.hasArg(options::OPT_shared) || TC.getTriple().isAndroid()) {
 // Don't link static runtimes into DSOs or if compiling for Android.
 return;
   }
@@ -3042,7 +3041,7 @@
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
 
   // Android-specific defaults for PIC/PIE
-  if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) {
+  if (ToolChain.getTriple().isAndroid()) {
 switch (ToolChain.getArch()) {
 case llvm::Triple::arm:
 case llvm::Triple::armeb:
@@ -4241,7 +4240,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   // Emulated TLS is enabled by default on Android, and can be enabled manually
   // with -femulated-tls.
-  bool EmulatedTLSDefault = Triple.getEnvironment() == llvm::Triple::Android;
+  bool EmulatedTLSDefault = Triple.isAndroid();
   if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
EmulatedTLSDefault))
 CmdArgs.push_back("-femulated-tls");
@@ -8170,7 +8169,7 @@
 
 static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
   ArgStringList &CmdArgs, const ArgList &Args) {
-  bool isAndroid = Triple.getEnvironment() == llvm::Triple::Android;
+  bool isAndroid = Triple.isAndroid();
   bool isCygMing = Triple.isOSCygMing();
   bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
   Args.hasArg(options::OPT_static);
@@ -8206,7 +8205,7 @@
  const toolchains::Linux &ToolChain) {
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
 
-  if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) {
+  if (ToolChain.getTriple().isAndroid()) {
 if (ToolChain.getTriple().isArch64Bit())
   return "/system/bin/linker64";
 else
@@ -8354,8 +8353,7 @@
   llvm::Triple Triple = llvm::Triple(TripleStr);
 
   const llvm::Triple::ArchType Arch = ToolChain.getArch();
-  const bool isAndroid =
-  ToolChain.getTriple().getEnvironment() == llvm::Triple::Android;
+  const bool isAndroid = ToolChain.getTriple().isAndroid();
   const bool IsPIE =
   !Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_static) &&
   (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault());
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1823,7 +1823,7 @@
   addMultilibFlag(isMipsEL(TargetArch), "EL", Flags);
   addMultilibFlag(!isMipsEL(TargetArch), "EB", Flags);
 
-  if (TargetTriple.getEnvironment() == llvm::Triple::Android) {
+  if (TargetTriple.isAndroid()) {
 // Select Android toolchain. It's the only choice in that case.
 if (AndroidMipsMultilibs.select(Flags, Result.SelectedMultilib)) {
   Result.Multilibs = AndroidMipsMultilibs;
@@ -2174,8 +2174,7 @@
   

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
Hey!

I think you are right. This will not regress any of the cases, because previous 
behaviour either checked str.size() >= 4 OR didn’t check it at all, but then 
called .substr(2, str.size() - 4), which would crash. I think, though, that 
explicitly checking str.size() >= 4 makes sense. See comments below.
I will have a patch to fix it up. See comments below.

Adrian
> On Oct 8, 2015, at 1:21 PM, Aaron Ballman  wrote:
> 
> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith  wrote:
>> On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>>  wrote:
>>> 
>>> Author: aaronballman
>>> Date: Thu Oct  8 14:24:08 2015
>>> New Revision: 249721
>>> 
>>> URL: 
>>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=I7JuuiH4eEYBv1meYlgoiyDdl9yvM1r3kGhI0NE1f2g%3D%0A&s=4eae7d09ce0f4330138bcb73d7c5b39ae009250829081e6ef41033dc71e8bfc4
>>> Log:
>>> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
>>> GNU-style formatting that involves prefix and suffix underscores. Cleans up
>>> other usages of similar functionality.
>>> 
>>> Patch by Adrian Zgorzalek!
>>> 
>>> Modified:
>>>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>>>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>>>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>>> 
>>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> URL:
>>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=I7JuuiH4eEYBv1meYlgoiyDdl9yvM1r3kGhI0NE1f2g%3D%0A&s=d7e208b0f19fa5d62b635aab96f22ed209d3ffb85762228e4cd2f87ff1cf1983
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>>> AssumeAlignedAttr(AttrRange, Context, E, OE,
>>> SpellingListIndex));
>>> }
>>> 
>>> +/// Normalize the attribute, __foo__ becomes foo.
>>> +/// Returns true if normalization was applied.
>>> +static bool normalizeName(StringRef &AttrName) {
>>> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {

I will make it:
+  if (AttrName.size() >= 4 && AttrName.startswith("__") && 
AttrName.endswith("__”)) {

>>> 
>>> +assert(AttrName.size() > 4 && "Name too short");
>> 
>> 
>> This assert will fire on the strings __, ___, and , which are valid in
>> some of the below cases.
> 
> That assert won't fire on anything but  because it's &&, not ||. I
> don't think these names were intended to be valid in their uses.
> However, you are correct that this will trigger assertions instead of
> diagnostics. Adrian, can you investigate?
> 
>> 
>>> 
>>> +AttrName = AttrName.drop_front(2).drop_back(2);
>>> +return true;
>>> +  }
>>> +  return false;
>>> +}
>>> +
>>> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>>> &AL) {
>>>   // This attribute must be applied to a function declaration. The first
>>>   // argument to the attribute must be an identifier, the name of the
>>> resource,
>>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>>> 
>>>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>>> 
>>> -  // Normalize the argument, __foo__ becomes foo.
>>>   StringRef ModuleName = Module->getName();
>>> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>>> -  ModuleName.size() > 4) {
Checks size, so is fine.
>>> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>>> +  if (normalizeName(ModuleName)) {
>>> Module = &S.PP.getIdentifierTable().get(ModuleName);
>>>   }
>>> 
>>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>>>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Format = II->getName();
>>> 
>>> -  // Normalize the argument, __foo__ becomes foo.
>>> -  if (Format.startswith("__") && Format.endswith("__")) {
>>> -Format = Format.substr(2, Format.size() - 4);
- 4, so it would crash if shorter than 4 chars
>> 
>>> +  if (normalizeName(Format)) {
>>> // If we've modified the string name, we need a new identifier for
>>> it.
>>> II = &S.Context.Idents.get(Format);
>>>   }
>>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>>>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>>>   StringRef Str = Name->getName();
>>> 
>>> -  // Normalize the attribute name, __foo__ becomes foo.
>>> -  if (Str.startswith("__") && Str.endswith("__"))
>>> -Str = Str.substr(2, Str.size() - 4);
>>> +  normalizeName(Str);
>>> 
- 4, so it would crash if shorter than 4 chars
>>>   unsigned DestWidth = 0;
>>>   bool IntegerMode = true;
>>> @@ -4533,

[libcxx] r249743 - Split out of .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 15:41:26 2015
New Revision: 249743

URL: http://llvm.org/viewvc/llvm-project?rev=249743&view=rev
Log:
Split  out of .

Added:
libcxx/trunk/include/setjmp.h
  - copied, changed from r249736, libcxx/trunk/include/csetjmp
Modified:
libcxx/trunk/include/csetjmp
libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp

Modified: libcxx/trunk/include/csetjmp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/csetjmp?rev=249743&r1=249742&r2=249743&view=diff
==
--- libcxx/trunk/include/csetjmp (original)
+++ libcxx/trunk/include/csetjmp Thu Oct  8 15:41:26 2015
@@ -38,10 +38,6 @@ void longjmp(jmp_buf env, int val);
 #pragma GCC system_header
 #endif
 
-#ifndef setjmp
-#define setjmp(env) setjmp(env)
-#endif
-
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::jmp_buf;

Copied: libcxx/trunk/include/setjmp.h (from r249736, 
libcxx/trunk/include/csetjmp)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/setjmp.h?p2=libcxx/trunk/include/setjmp.h&p1=libcxx/trunk/include/csetjmp&r1=249736&r2=249743&rev=249743&view=diff
==
--- libcxx/trunk/include/csetjmp (original)
+++ libcxx/trunk/include/setjmp.h Thu Oct  8 15:41:26 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--- csetjmp 
--===//
+//===--- setjmp.h 
-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -8,31 +8,26 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_CSETJMP
-#define _LIBCPP_CSETJMP
+#ifndef _LIBCPP_SETJMP_H
+#define _LIBCPP_SETJMP_H
 
 /*
-csetjmp synopsis
+setjmp.h synopsis
 
 Macros:
 
 setjmp
 
-namespace std
-{
-
 Types:
 
 jmp_buf
 
 void longjmp(jmp_buf env, int val);
 
-}  // std
-
 */
 
 #include <__config>
-#include 
+#include_next 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -42,11 +37,4 @@ void longjmp(jmp_buf env, int val);
 #define setjmp(env) setjmp(env)
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-using ::jmp_buf;
-using ::longjmp;
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif  // _LIBCPP_CSETJMP
+#endif  // _LIBCPP_SETJMP_H

Modified: libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp?rev=249743&r1=249742&r2=249743&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/setjmp_h.pass.cpp Thu Oct  8 
15:41:26 2015
@@ -12,6 +12,10 @@
 #include 
 #include 
 
+#ifndef setjmp
+#error setjmp not defined
+#endif
+
 int main()
 {
 jmp_buf jb;


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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
wrote:

> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
> wrote:
> > On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
> >  wrote:
> >>
> >> Author: aaronballman
> >> Date: Thu Oct  8 14:24:08 2015
> >> New Revision: 249721
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
> >> Log:
> >> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> >> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> >> other usages of similar functionality.
> >>
> >> Patch by Adrian Zgorzalek!
> >>
> >> Modified:
> >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> >> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> >>  AssumeAlignedAttr(AttrRange, Context, E, OE,
> >> SpellingListIndex));
> >>  }
> >>
> >> +/// Normalize the attribute, __foo__ becomes foo.
> >> +/// Returns true if normalization was applied.
> >> +static bool normalizeName(StringRef &AttrName) {
> >> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> >> +assert(AttrName.size() > 4 && "Name too short");
> >
> >
> > This assert will fire on the strings __, ___, and , which are valid
> in
> > some of the below cases.
>
> That assert won't fire on anything but  because it's &&, not ||.


I disagree. __ starts with __ and ends with __. The right thing to do here
is remove the assert and put back the AttrName.size() > 4 check that the
callers used to have.

I
> don't think these names were intended to be valid in their uses.
> However, you are correct that this will trigger assertions instead of
> diagnostics. Adrian, can you investigate?
>
> >
> >>
> >> +AttrName = AttrName.drop_front(2).drop_back(2);
> >> +return true;
> >> +  }
> >> +  return false;
> >> +}
> >> +
> >>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> >> &AL) {
> >>// This attribute must be applied to a function declaration. The
> first
> >>// argument to the attribute must be an identifier, the name of the
> >> resource,
> >> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
> >>
> >>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
> >>
> >> -  // Normalize the argument, __foo__ becomes foo.
> >>StringRef ModuleName = Module->getName();
> >> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> >> -  ModuleName.size() > 4) {
> >> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> >> +  if (normalizeName(ModuleName)) {
> >>  Module = &S.PP.getIdentifierTable().get(ModuleName);
> >>}
> >>
> >> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
> >>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
> >>StringRef Format = II->getName();
> >>
> >> -  // Normalize the argument, __foo__ becomes foo.
> >> -  if (Format.startswith("__") && Format.endswith("__")) {
> >> -Format = Format.substr(2, Format.size() - 4);
> >> +  if (normalizeName(Format)) {
> >>  // If we've modified the string name, we need a new identifier for
> >> it.
> >>  II = &S.Context.Idents.get(Format);
> >>}
> >> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
> >>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
> >>StringRef Str = Name->getName();
> >>
> >> -  // Normalize the attribute name, __foo__ becomes foo.
> >> -  if (Str.startswith("__") && Str.endswith("__"))
> >> -Str = Str.substr(2, Str.size() - 4);
> >> +  normalizeName(Str);
> >>
> >>unsigned DestWidth = 0;
> >>bool IntegerMode = true;
> >> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
> >>
> >>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
> >>   const AttributeList &Attr) {
> >> +  StringRef AttrName = Attr.getName()->getName();
> >> +  normalizeName(AttrName);
> >>std::string SanitizerName =
> >> -  llvm::StringSwitch(Attr.getName()->getName())
> >> +  llvm::StringSwitch(AttrName)
> >>.Case("no_address_safety_analysis", "address")
> >>.Case("no_sanitize_address", "address")
> >>.Case("no_sanitize_thread", "thread")
> >
> >
> > Is there any way we could use the spelling list index in this case rather
> > than repeating the attribute names and __-stripping here?
>
> The spelling list index isn't exposed in a meaningful way (and I t

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Aaron Ballman via cfe-commits
On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith  wrote:
> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
> wrote:
>>
>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>> wrote:
>> > On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>> >  wrote:
>> >>
>> >> Author: aaronballman
>> >> Date: Thu Oct  8 14:24:08 2015
>> >> New Revision: 249721
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=249721&view=rev
>> >> Log:
>> >> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
>> >> GNU-style formatting that involves prefix and suffix underscores.
>> >> Cleans up
>> >> other usages of similar functionality.
>> >>
>> >> Patch by Adrian Zgorzalek!
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>> >> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>> >>
>> >> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249721&r1=249720&r2=249721&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> >> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>> >> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>> >>  AssumeAlignedAttr(AttrRange, Context, E, OE,
>> >> SpellingListIndex));
>> >>  }
>> >>
>> >> +/// Normalize the attribute, __foo__ becomes foo.
>> >> +/// Returns true if normalization was applied.
>> >> +static bool normalizeName(StringRef &AttrName) {
>> >> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> >> +assert(AttrName.size() > 4 && "Name too short");
>> >
>> >
>> > This assert will fire on the strings __, ___, and , which are valid
>> > in
>> > some of the below cases.
>>
>> That assert won't fire on anything but  because it's &&, not ||.
>
>
> I disagree. __ starts with __ and ends with __. The right thing to do here
> is remove the assert and put back the AttrName.size() > 4 check that the
> callers used to have.

Hah, you are correct. I hadn't considered that point. I agree with you. :-)

~Aaron

>
>> I
>> don't think these names were intended to be valid in their uses.
>> However, you are correct that this will trigger assertions instead of
>> diagnostics. Adrian, can you investigate?
>>
>> >
>> >>
>> >> +AttrName = AttrName.drop_front(2).drop_back(2);
>> >> +return true;
>> >> +  }
>> >> +  return false;
>> >> +}
>> >> +
>> >>  static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
>> >> &AL) {
>> >>// This attribute must be applied to a function declaration. The
>> >> first
>> >>// argument to the attribute must be an identifier, the name of the
>> >> resource,
>> >> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>> >>
>> >>IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>> >>
>> >> -  // Normalize the argument, __foo__ becomes foo.
>> >>StringRef ModuleName = Module->getName();
>> >> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> >> -  ModuleName.size() > 4) {
>> >> -ModuleName = ModuleName.drop_front(2).drop_back(2);
>> >> +  if (normalizeName(ModuleName)) {
>> >>  Module = &S.PP.getIdentifierTable().get(ModuleName);
>> >>}
>> >>
>> >> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>> >>IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>> >>StringRef Format = II->getName();
>> >>
>> >> -  // Normalize the argument, __foo__ becomes foo.
>> >> -  if (Format.startswith("__") && Format.endswith("__")) {
>> >> -Format = Format.substr(2, Format.size() - 4);
>> >> +  if (normalizeName(Format)) {
>> >>  // If we've modified the string name, we need a new identifier for
>> >> it.
>> >>  II = &S.Context.Idents.get(Format);
>> >>}
>> >> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>> >>IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>> >>StringRef Str = Name->getName();
>> >>
>> >> -  // Normalize the attribute name, __foo__ becomes foo.
>> >> -  if (Str.startswith("__") && Str.endswith("__"))
>> >> -Str = Str.substr(2, Str.size() - 4);
>> >> +  normalizeName(Str);
>> >>
>> >>unsigned DestWidth = 0;
>> >>bool IntegerMode = true;
>> >> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S
>> >>
>> >>  static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
>> >>   const AttributeList &Attr) {
>> >> +  StringRef AttrName = Attr.getName()->getName();
>> >> +  normalizeName(AttrName);
>> >>std::string SanitizerName =
>> >> -  llvm::StringSwitch(Attr.getName()->getName())
>> >> +  llvm::StringSwitch(AttrName)
>> >>.Case("no_address_safety_analysis", "address")
>> >>.Case("no_sanitize_addres

Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute.

2015-10-08 Thread Alexey Bataev via cfe-commits
ABataev marked 2 inline comments as done.


Comment at: lib/AST/DeclPrinter.cpp:197
@@ -196,3 +196,3 @@
 
-void DeclPrinter::prettyPrintAttributes(Decl *D) {
+void DeclPrinter::prettyPrintAttributes(Decl *D, bool PrintPragmas) {
   if (Policy.PolishForDeclaration)

aaron.ballman wrote:
> Would it make more sense to add a prettyPrintPragmas(Decl *D) function 
> instead?
Ok, will do


Comment at: test/SemaCXX/pragma-init_seg.cpp:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
x86_64-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
x86_64-pc-win32 -ast-print | FileCheck %s
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple 
i386-apple-darwin13.3.0

aaron.ballman wrote:
> I think this should be a new test under Misc\. We have ast-print-pragmas.cpp 
> that looks like a good place for it to go.
Ok


http://reviews.llvm.org/D13546



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


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D13572



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


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Eric Christopher via cfe-commits
Pending naming from llvm review, LGTM.

On Thu, Oct 8, 2015 at 1:55 PM Stephen Hines  wrote:

> srhines added a comment.
>
> LGTM
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D13572
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

Pending naming from llvm review, LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D13572



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


Re: [PATCH] D13304: Avoid inlining in throw statement

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 9:54 AM,  wrote:

> > I think this actually makes it less general. You would presumably perform
> > different inlining for:
> >
> >   throw f(x, y);
> >
> > versus
> >
> >   auto k = f(x, y);
> >   throw k;
>
> We need to differentiate between these two. For the second case, we should
> not add any attribute because it’s not invoked in the EH region and it
> could have any other purposes other than exception handling. I believe we
> need to specifically handle only the case where we can guarantee that the
> call is invoked only in exception handling context.


Modulo copying the value returned by f, those two are equivalent, and it's
entirely reasonable to want to refactor one into the other. Such
refactoring should not affect the optimizer's behavior on this code. Why do
you think they should be treated differently?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits
You are right, my bad, I thought this if covers all the cases, but  part 
could be empty.

Here is the fix:



Adrian
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman  wrote:
>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith  wrote:
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> wrote:
>>>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>>> wrote:
 On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
  wrote:
>
> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: 
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
>
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");


 This assert will fire on the strings __, ___, and , which are valid
 in
 some of the below cases.
>>>
>>> That assert won't fire on anything but  because it's &&, not ||.
>>
>>
>> I disagree. __ starts with __ and ends with __. The right thing to do here
>> is remove the assert and put back the AttrName.size() > 4 check that the
>> callers used to have.
>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)
>
> ~Aaron
>
>>
>>> I
>>> don't think these names were intended to be valid in their uses.
>>> However, you are correct that this will trigger assertions instead of
>>> diagnostics. Adrian, can you investigate?
>>>

>
> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>   // This attribute must be applied to a function declaration. The
> first
>   // argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>
>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>   StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeName(ModuleName)) {
> Module = &S.PP.getIdentifierTable().get(ModuleName);
>   }
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
>   StringRef Format = II->getName();
>
> -  // Normalize the argument, __foo__ becomes foo.
> -  if (Format.startswith("__") && Format.endswith("__")) {
> -Format = Format.substr(2, Format.size() - 4);
> +  if (normalizeName(Format)) {
> // If we've modified the string name, we need a new identifier for
> it.
> II = &S.Context.Idents.get(Format);
>   }
> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl
>   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
>   StringRef Str = Name->getName();
>
> -  // Normalize the attribute name, __foo__ becomes foo.
> -  if (Str.startswith("__") && Str.endswith("__"))
> -Str = Str.substr(2,

r249748 - [WinEH] Push cleanupendpad scopes around exceptional cleanups

2015-10-08 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Oct  8 16:14:56 2015
New Revision: 249748

URL: http://llvm.org/viewvc/llvm-project?rev=249748&view=rev
Log:
[WinEH] Push cleanupendpad scopes around exceptional cleanups

We were only doing this for SEH as a special case. Generalize it to all
cleanups.

Modified:
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=249748&r1=249747&r2=249748&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Thu Oct  8 16:14:56 2015
@@ -521,15 +521,6 @@ static void EmitCleanup(CodeGenFunction
 EHScopeStack::Cleanup *Fn,
 EHScopeStack::Cleanup::Flags flags,
 Address ActiveFlag) {
-  // Itanium EH cleanups occur within a terminate scope. Microsoft SEH doesn't
-  // have this behavior, and the Microsoft C++ runtime will call terminate for
-  // us if the cleanup throws.
-  bool PushedTerminate = false;
-  if (flags.isForEHCleanup() && !CGF.getTarget().getCXXABI().isMicrosoft()) {
-CGF.EHStack.pushTerminate();
-PushedTerminate = true;
-  }
-
   // If there's an active flag, load it and skip the cleanup if it's
   // false.
   llvm::BasicBlock *ContBB = nullptr;
@@ -549,10 +540,6 @@ static void EmitCleanup(CodeGenFunction
   // Emit the continuation block if there was an active flag.
   if (ActiveFlag.isValid())
 CGF.EmitBlock(ContBB);
-
-  // Leave the terminate scope.
-  if (PushedTerminate)
-CGF.EHStack.popTerminate();
 }
 
 static void ForwardPrebranchedFallthrough(llvm::BasicBlock *Exit,
@@ -931,11 +918,29 @@ void CodeGenFunction::PopCleanupBlock(bo
 CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
 
 EmitBlock(EHEntry);
+
+// Push terminate scopes around the potentially throwing destructor calls.
+// We don't emit these when using funclets, because the runtime does it for
+// us as part of unwinding out of a cleanuppad.
+bool PushedTerminate = false;
+if (!EHPersonality::get(*this).usesFuncletPads()) {
+  EHStack.pushTerminate();
+  PushedTerminate = true;
+}
+
 llvm::CleanupPadInst *CPI = nullptr;
+llvm::BasicBlock *CleanupEndBB = nullptr;
 llvm::BasicBlock *NextAction = getEHDispatchBlock(EHParent);
-if (EHPersonality::get(*this).usesFuncletPads())
+if (EHPersonality::get(*this).usesFuncletPads()) {
   CPI = Builder.CreateCleanupPad({});
 
+  // Build a cleanupendpad to unwind through. Our insertion point should be
+  // in the cleanuppad block.
+  CleanupEndBB = createBasicBlock("ehcleanup.end");
+  CGBuilderTy(*this, CleanupEndBB).CreateCleanupEndPad(CPI, NextAction);
+  EHStack.pushPadEnd(CleanupEndBB);
+}
+
 // We only actually emit the cleanup code if the cleanup is either
 // active or was used before it was deactivated.
 if (EHActiveFlag.isValid() || IsActive) {
@@ -948,6 +953,21 @@ void CodeGenFunction::PopCleanupBlock(bo
 else
   Builder.CreateBr(NextAction);
 
+// Insert the cleanupendpad block here, if it has any uses.
+if (CleanupEndBB) {
+  EHStack.popPadEnd();
+  if (CleanupEndBB->hasNUsesOrMore(1)) {
+CurFn->getBasicBlockList().insertAfter(Builder.GetInsertBlock(),
+   CleanupEndBB);
+  } else {
+delete CleanupEndBB;
+  }
+}
+
+// Leave the terminate scope.
+if (PushedTerminate)
+  EHStack.popTerminate();
+
 Builder.restoreIP(SavedIP);
 
 SimplifyCleanupEntry(*this, EHEntry);

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=249748&r1=249747&r2=249748&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Oct  8 16:14:56 2015
@@ -1410,10 +1410,8 @@ void CodeGenFunction::EmitSEHTryStmt(con
 namespace {
 struct PerformSEHFinally final : EHScopeStack::Cleanup {
   llvm::Function *OutlinedFinally;
-  EHScopeStack::stable_iterator EnclosingScope;
-  PerformSEHFinally(llvm::Function *OutlinedFinally,
-EHScopeStack::stable_iterator EnclosingScope)
-  : OutlinedFinally(OutlinedFinally), EnclosingScope(EnclosingScope) {}
+  PerformSEHFinally(llvm::Function *OutlinedFinally)
+  : OutlinedFinally(OutlinedFinally) {}
 
   void Emit(CodeGenFunction &CGF, Flags F) override {
 ASTContext &Context = CGF.getContext();
@@ -1438,28 +1436,7 @@ struct PerformSEHFinally final : EHScope
 CGM.getTypes().arrangeFreeFunctionCall(Args, FPT,
/*chainCall=*/false)

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> You are right, my bad, I thought this if covers all the cases, but 
> part could be empty.
>
> Here is the fix
>

Please add a testcase ("__attribute__((ownership_takes(__))) void f();"
maybe?).

The '&&' should go at the end of the previous line.

Adrian
> > On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> wrote:
> >
> > On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> wrote:
> >> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
> >> wrote:
> >>>
> >>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
> >>> wrote:
>  On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>   wrote:
> >
> > Author: aaronballman
> > Date: Thu Oct  8 14:24:08 2015
> > New Revision: 249721
> >
> > URL:
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> > Log:
> > When mapping no_sanitize_* attributes to no_sanitize attributes,
> handle
> > GNU-style formatting that involves prefix and suffix underscores.
> > Cleans up
> > other usages of similar functionality.
> >
> > Patch by Adrian Zgorzalek!
> >
> > Modified:
> >cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
> >cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > URL:
> >
> >
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
> >
> >
> >
> ==
> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> > @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> > AssumeAlignedAttr(AttrRange, Context, E, OE,
> > SpellingListIndex));
> > }
> >
> > +/// Normalize the attribute, __foo__ becomes foo.
> > +/// Returns true if normalization was applied.
> > +static bool normalizeName(StringRef &AttrName) {
> > +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> > +assert(AttrName.size() > 4 && "Name too short");
> 
> 
>  This assert will fire on the strings __, ___, and , which are
> valid
>  in
>  some of the below cases.
> >>>
> >>> That assert won't fire on anything but  because it's &&, not ||.
> >>
> >>
> >> I disagree. __ starts with __ and ends with __. The right thing to do
> here
> >> is remove the assert and put back the AttrName.size() > 4 check that the
> >> callers used to have.
> >
> > Hah, you are correct. I hadn't considered that point. I agree with you.
> :-)
> >
> > ~Aaron
> >
> >>
> >>> I
> >>> don't think these names were intended to be valid in their uses.
> >>> However, you are correct that this will trigger assertions instead of
> >>> diagnostics. Adrian, can you investigate?
> >>>
> 
> >
> > +AttrName = AttrName.drop_front(2).drop_back(2);
> > +return true;
> > +  }
> > +  return false;
> > +}
> > +
> > static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> > &AL) {
> >   // This attribute must be applied to a function declaration. The
> > first
> >   // argument to the attribute must be an identifier, the name of the
> > resource,
> > @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
> >
> >   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
> >
> > -  // Normalize the argument, __foo__ becomes foo.
> >   StringRef ModuleName = Module->getName();
> > -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> > -  ModuleName.size() > 4) {
> > -ModuleName = ModuleName.drop_front(2).drop_back(2);
> > +  if (normalizeName(ModuleName)) {
> > Module = &S.PP.getIdentifierTable().get(ModuleName);
> >   }
> >
> > @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
> >   IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
> >   StringRef Format = II->getName();
> >
> > -  // Normalize the argument, __foo__ becomes foo.
> > -  if (Format.startswith("__") && Format.endswith("__")) {
> > -Format = Format.substr(2, Format.size() - 4);
> > +  if (normalizeName(Format)) {

[libcxx] r249749 - Fix incorrect file header. This is not .

2015-10-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  8 16:17:21 2015
New Revision: 249749

URL: http://llvm.org/viewvc/llvm-project?rev=249749&view=rev
Log:
Fix incorrect file header. This is  not .

Modified:
libcxx/trunk/include/cfenv

Modified: libcxx/trunk/include/cfenv
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cfenv?rev=249749&r1=249748&r2=249749&view=diff
==
--- libcxx/trunk/include/cfenv (original)
+++ libcxx/trunk/include/cfenv Thu Oct  8 16:17:21 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//=== cctype 
--===//
+//=== cfenv 
---===//
 //
 // The LLVM Compiler Infrastructure
 //


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


r249751 - Use Triple.isAndroid() where possible.

2015-10-08 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Thu Oct  8 16:21:44 2015
New Revision: 249751

URL: http://llvm.org/viewvc/llvm-project?rev=249751&view=rev
Log:
Use Triple.isAndroid() where possible.

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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Oct  8 16:21:44 2015
@@ -383,7 +383,7 @@ protected:
 DefineStd(Builder, "linux", Opts);
 Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
-if (Triple.getEnvironment() == llvm::Triple::Android) {
+if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
   unsigned Maj, Min, Rev;
   Triple.getEnvironmentVersion(Maj, Min, Rev);

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Oct  8 16:21:44 2015
@@ -495,10 +495,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
 
   if (AllAddedKinds & Address) {
 AsanSharedRuntime =
-Args.hasArg(options::OPT_shared_libasan) ||
-(TC.getTriple().getEnvironment() == llvm::Triple::Android);
-AsanZeroBaseShadow =
-(TC.getTriple().getEnvironment() == llvm::Triple::Android);
+Args.hasArg(options::OPT_shared_libasan) || TC.getTriple().isAndroid();
+AsanZeroBaseShadow = TC.getTriple().isAndroid();
 if (Arg *A =
 Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
 StringRef S = A->getValue();

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Oct  8 16:21:44 2015
@@ -284,8 +284,7 @@ static StringRef getArchNameForCompilerR
 std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
  bool Shared) const {
   const llvm::Triple &TT = getTriple();
-  const char *Env =
-  (TT.getEnvironment() == llvm::Triple::Android) ? "-android" : "";
+  const char *Env = TT.isAndroid() ? "-android" : "";
   bool IsITANMSVCWindows =
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct  8 16:21:44 2015
@@ -1823,7 +1823,7 @@ static bool findMIPSMultilibs(const llvm
   addMultilibFlag(isMipsEL(TargetArch), "EL", Flags);
   addMultilibFlag(!isMipsEL(TargetArch), "EB", Flags);
 
-  if (TargetTriple.getEnvironment() == llvm::Triple::Android) {
+  if (TargetTriple.isAndroid()) {
 // Select Android toolchain. It's the only choice in that case.
 if (AndroidMipsMultilibs.select(Flags, Result.SelectedMultilib)) {
   Result.Multilibs = AndroidMipsMultilibs;
@@ -2174,8 +2174,7 @@ void Generic_ELF::addClangTargetOptions(
   getTriple().getArch() == llvm::Triple::aarch64 ||
   getTriple().getArch() == llvm::Triple::aarch64_be ||
   (getTriple().getOS() == llvm::Triple::Linux &&
-   (!V.isOlderThan(4, 7, 0) ||
-getTriple().getEnvironment() == llvm::Triple::Android)) ||
+   (!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) ||
   getTriple().getOS() == llvm::Triple::NaCl;
 
   if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
@@ -3329,7 +3328,7 @@ Linux::Linux(const Driver &D, const llvm
   if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
 ExtraOpts.push_back("-X");
 
-  const bool IsAndroid = Triple.getEnvironment() == llvm::Triple::Android;
+  const bool IsAndroid = Triple.isAndroid();
   const bool IsMips = isMipsArch(Arch);
 
   if (IsMips && !SysRoot.empty())

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=249751&r1=249750&r2=249751&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct  8 16:21:44 2015
@@ -989,7 +989,7 @@ void Clan

Re: [PATCH] D13572: Use Triple.isAndroid() where possible.

2015-10-08 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r249751


Repository:
  rL LLVM

http://reviews.llvm.org/D13572



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


Re: [PATCH] D12726: [analyzer] A fix for symbolic element region index lifetime.

2015-10-08 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Now that we have a way to test symbol reaper, please, add more coverage to the 
symbol-reaper.c test, including the test that Jordan mentioned. Even if it is 
not fixed, it's good to include it with a FIXME note.

What is the performance impact of this change?

The changes to the RegionStore and Environment seem inconsistent and 
repetitive.. For example, we can remove a lot of this just by changing 
SymbolReaper::markLive(const MemRegion *region), see below. How is this patch 
different from your solution? Can it be generalized to handle more cases?

  diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/lib/StaticAnalyzer/Core/RegionStore.cpp
  index 49b5ac3..55db545 100644
  --- a/lib/StaticAnalyzer/Core/RegionStore.cpp
  +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp
  @@ -2320,8 +2320,14 @@ void removeDeadBindingsWorker::VisitCluster(const 
MemRegion *baseR,
 if (const SymbolicRegion *SymR = dyn_cast(baseR))
   SymReaper.markLive(SymR->getSymbol());
   
  -  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I)
  +  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I) {
  +// Mark the key of each binding as live.
  +const BindingKey &K = I.getKey();
  +if (auto subR = dyn_cast(K.getRegion()))
  +  SymReaper.markLive(subR);
  +
   VisitBinding(I.getData());
  +  }
   }
   
   void removeDeadBindingsWorker::VisitBinding(SVal V) {
  @@ -2342,6 +2348,7 @@ void removeDeadBindingsWorker::VisitBinding(SVal V) {
 // If V is a region, then add it to the worklist.
 if (const MemRegion *R = V.getAsRegion()) {
   AddToWorkList(R);
  +SymReaper.markLive(R);
   
   // All regions captured by a block are also live.
   if (const BlockDataRegion *BR = dyn_cast(R)) {
  diff --git a/lib/StaticAnalyzer/Core/SymbolManager.cpp 
b/lib/StaticAnalyzer/Core/SymbolManager.cpp
  index df4d22a..793f53e 100644
  --- a/lib/StaticAnalyzer/Core/SymbolManager.cpp
  +++ b/lib/StaticAnalyzer/Core/SymbolManager.cpp
  @@ -391,6 +391,16 @@ void SymbolReaper::markLive(SymbolRef sym) {
   
   void SymbolReaper::markLive(const MemRegion *region) {
 RegionRoots.insert(region);
  +  
  +  // Mark the element index as live.
  +  if (const ElementRegion *ER = dyn_cast(region)) {
  +SVal Idx = ER->getIndex();
  +for (SymExpr::symbol_iterator SI = Idx.symbol_begin(),
  + SE = Idx.symbol_end();
  + SI != SE; ++SI) {
  +  markLive(*SI);
  +}
  +  }
   }



Comment at: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp:177
@@ +176,3 @@
+
+C.emitReport(llvm::make_unique(*BT, "SYMBOL DEAD", N));
+  }

Thank you for adding this!!! This can be part of this commit or separate; up to 
you.

Please, update the debugger checkers document in the docs folder with 
information on how this should be used.


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2241
@@ +2240,3 @@
+  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I) {
+
+// Mark the index symbol of any ElementRegion key as live.

Please, remove unnecessary spacing here and in a couple of other places.


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2247
@@ +2246,3 @@
+  if (auto elemR = dyn_cast(subR))
+if (SymbolRef Sym = elemR->getIndex().getAsSymbol())
+  SymReaper.markLive(Sym);

Why symbol_iterator is not used here?


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2249
@@ +2248,3 @@
+  SymReaper.markLive(Sym);
+  subR = dyn_cast(subR->getSuperRegion());
+}

Could you add test cases that explain why we need the while loop here?


http://reviews.llvm.org/D12726



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


Re: Implict casts disappeared from syntactic init list expressions in C++

2015-10-08 Thread Richard Smith via cfe-commits
There are some other open problems in this area:

- RecursiveASTVisitor on nested InitListExprs is currently worst-case
exponential time because it walks the syntactic and semantic forms
separately
- Tools such as "find all references to this function" need the semantic
form of every initializer, whether or not that initializer is actually used
for the initialization (it might be overridden through the use of a
designator)
- ...

Having thought about this for a while, I think the right answer is this:

The only difference between the syntactic and semantic forms of an
InitListExpr should be designated initializers and brace elision. In all
other respects, the syntactic and semantic forms should be identical -- in
particular, both should contain the results of performing the relevant
initialization sequences on the list elements, and we should extend the
syntactic form to include the implicit initializations for trailing
elements.

With that in hand, we should make RecursiveASTVisitor visit /only/ the
syntactic form. The semantic ("simplified") form should only be used in
places where we want to know the semantic effect of the initialization
(after applying the designated initialization overriding rules and
inserting the elided braces), and is always derivable in a fairly
straightforward fashion from the syntactic form.

I think that's largely what you were suggesting below. Do you agree?

On Wed, Oct 7, 2015 at 11:54 PM, Abramo Bagnara 
wrote:

> Ping^2
>
> Il 12/09/2015 09:40, Abramo Bagnara ha scritto:
> > Ping...
> >
> > Il 29/08/2015 10:01, Abramo Bagnara ha scritto:
> >> Il 28/08/2015 23:27, Richard Smith ha scritto:
> >>> On Tue, Aug 25, 2015 at 10:27 AM, Abramo Bagnara
> >>> mailto:abramo.bagn...@bugseng.com>>
> wrote:
> >>>
> >>> Comparing the result of InitListExpr::getSyntacticForm between
> r224986
> >>> and r245836 I've discovered that integer to char implicit cast for
> >>> integer literal 3 is no longer added to AST for C++ (while it is
> present
> >>> in C).
> >>>
> >>> This is the source used to test:
> >>>
> >>> char v[10] = { 3 };
> >>>
> >>> Taken in account that:
> >>>
> >>> - implicit cast (and other conversions, constructor calls, etc.)
> are
> >>> very important also for who need to visit the syntactic form
> (obvious in
> >>> *both* C and C++)
> >>>
> >>> - to generate that for the syntactic form permit to increase the
> >>> efficiency and the sharing when using designated range extensions
> (as
> >>> the conversion chain don't need to be replicated for each entry)
> >>>
> >>> I think it is a regression. Am I missing something?
> >>>
> >>>
> >>> Why do you expect this semantic information to appear in the syntactic
> >>> form of the initializer?
> >>
> >> Compare:
> >>
> >> int x = 2.0;
> >>
> >> with
> >>
> >> struct s {
> >>   int x;
> >> } v = { .x = 2.0 };
> >>
> >> For first declaration I have non-syntactic nodes (namely
> >> ImplicitCastExpr) along with syntactic nodes, while for the second I
> >> don't have that (for C++). This is an obstacle to write semi-syntactic
> >> checkers that aims to find e.g. implicit cast from double to int in its
> >> syntactic context.
> >> Note that although we might visit the semantic form, we'll lose the
> >> designators (not present in semantic form).
> >>
> >> To resume, the reason why I would expect that are:
> >>
> >> 1) this is how it always has worked for C (and fortunately still works
> >> this way)
> >>
> >>
> >> 2) this is how it always has worked (although partially, there was some
> >> bugs) for C++. In past we have had patches to fix the areas where this
> >> invariant was not respected (see commit 3146766
> >>
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20111212/050339.html
> >> as an example).
> >>
> >> This behavior has changed rather recently (if you think it is useful I
> >> can find the commit that has removed the implicit casts from syntactic
> >> form in C++)
> >>
> >> Before such commit(s) the only bug I was aware where AST was missing
> >> conversion chain was the following:
> >>
> >> struct R2 {
> >>   R2(int) {
> >>   }
> >> };
> >> R2 v2[] = { 1.0 };
> >>
> >>
> >> 3) this way it would be congruent with other areas of AST where we have
> >> non-syntactic nodes along with syntactic ones
> >>
> >>
> >> 4) it would permit to share more nodes in semantic form (and avoid to
> >> rebuild many times the same conversion chain).
> >>
> >> Looking at following typescript you can observe that ImplicitCastExpr is
> >> shared only for C, but not for C++. I've initialized only two entries,
> >> but it might be 1000 or 1000.
> >>
> >> $ cat p.c
> >> int x[100] = { [0 ... 1] = 3.0 };
> >> $ clang-3.8 -cc1 -ast-dump -x c p.c
> >> TranslationUnitDecl 0x272de40 <> 
> >> |-TypedefDecl 0x272e338 <>  implicit
> >> __int128_t '__int128'
> >> |-TypedefDecl 0x272e398 <>  implicit
> >> __uint128_t 'unsigned __int128'
> >> |-TypedefDecl 0x272e648 <>  implicit
> >> __bu

Re: [PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-10-08 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Friendly Ping™


http://reviews.llvm.org/D12821



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


Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Adrian Zgorzalek via cfe-commits

On Oct 8, 2015, at 2:17 PM, Richard Smith 
mailto:rich...@metafoo.co.uk>> wrote:

On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
You are right, my bad, I thought this if covers all the cases, but  part 
could be empty.

Here is the fix

Please add a testcase ("__attribute__((ownership_takes(__))) void f();" maybe?).
I tried different attributes but none of them triggers the assert though. They 
all spit out warning:
warning: 'ownership_takes' attribute only applies to functions 
[-Wignored-attributes]
__attribute__((ownership_takes(__))) f();
   ^

Do you have some other idea?



The '&&' should go at the end of the previous line.

Adrian
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
> mailto:aa...@aaronballman.com>> wrote:
>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
> mailto:rich...@metafoo.co.uk>> wrote:
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> mailto:aa...@aaronballman.com>>
>> wrote:
>>>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>>> mailto:rich...@metafoo.co.uk>>
>>> wrote:
 On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
 mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: aaronballman
> Date: Thu Oct  8 14:24:08 2015
> New Revision: 249721
>
> URL: 
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
> Log:
> When mapping no_sanitize_* attributes to no_sanitize attributes, handle
> GNU-style formatting that involves prefix and suffix underscores.
> Cleans up
> other usages of similar functionality.
>
> Patch by Adrian Zgorzalek!
>
> Modified:
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
>
> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
> AssumeAlignedAttr(AttrRange, Context, E, OE,
> SpellingListIndex));
> }
>
> +/// Normalize the attribute, __foo__ becomes foo.
> +/// Returns true if normalization was applied.
> +static bool normalizeName(StringRef &AttrName) {
> +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
> +assert(AttrName.size() > 4 && "Name too short");


 This assert will fire on the strings __, ___, and , which are valid
 in
 some of the below cases.
>>>
>>> That assert won't fire on anything but  because it's &&, not ||.
>>
>>
>> I disagree. __ starts with __ and ends with __. The right thing to do here
>> is remove the assert and put back the AttrName.size() > 4 check that the
>> callers used to have.
>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)
>
> ~Aaron
>
>>
>>> I
>>> don't think these names were intended to be valid in their uses.
>>> However, you are correct that this will trigger assertions instead of
>>> diagnostics. Adrian, can you investigate?
>>>

>
> +AttrName = AttrName.drop_front(2).drop_back(2);
> +return true;
> +  }
> +  return false;
> +}
> +
> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList
> &AL) {
>   // This attribute must be applied to a function declaration. The
> first
>   // argument to the attribute must be an identifier, the name of the
> resource,
> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>
>   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>
> -  // Normalize the argument, __foo__ becomes foo.
>   StringRef ModuleName = Module->getName();
> -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
> -  ModuleName.size() > 4) {
> -ModuleName = ModuleName.drop_front(2).drop_back(2);
> +  if (normalizeName(ModuleName)) {
> Module = &S.PP.getIdentifierTable().get(ModuleName);
>   }
>
> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De
>   Id

Re: r249721 - When mapping no_sanitize_* attributes to no_sanitize attributes, handle GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality.

2015-10-08 Thread Richard Smith via cfe-commits
On Thu, Oct 8, 2015 at 2:45 PM, Adrian Zgorzalek  wrote:

>
> On Oct 8, 2015, at 2:17 PM, Richard Smith  wrote:
>
> On Thu, Oct 8, 2015 at 2:10 PM, Adrian Zgorzalek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> You are right, my bad, I thought this if covers all the cases, but 
>> part could be empty.
>>
>> Here is the fix
>>
>
> Please add a testcase ("__attribute__((ownership_takes(__))) void f();"
> maybe?).
>
> I tried different attributes but none of them triggers the assert though.
> They all spit out warning:
> warning: 'ownership_takes' attribute only applies to functions
> [-Wignored-attributes]
> __attribute__((ownership_takes(__))) f();
>^
>

You missed the 'void'.


> Do you have some other idea?
>
>
>
> The '&&' should go at the end of the previous line.
>
> Adrian
>> > On Oct 8, 2015, at 1:52 PM, Aaron Ballman 
>> wrote:
>> >
>> > On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith 
>> wrote:
>> >> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman 
>> >> wrote:
>> >>>
>> >>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith 
>> >>> wrote:
>>  On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits
>>   wrote:
>> >
>> > Author: aaronballman
>> > Date: Thu Oct  8 14:24:08 2015
>> > New Revision: 249721
>> >
>> > URL:
>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd
>> > Log:
>> > When mapping no_sanitize_* attributes to no_sanitize attributes,
>> handle
>> > GNU-style formatting that involves prefix and suffix underscores.
>> > Cleans up
>> > other usages of similar functionality.
>> >
>> > Patch by Adrian Zgorzalek!
>> >
>> > Modified:
>> >cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp
>> >cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp
>> >
>> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> > URL:
>> >
>> >
>> https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f
>> >
>> >
>> >
>> ==
>> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  8 14:24:08 2015
>> > @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa
>> > AssumeAlignedAttr(AttrRange, Context, E, OE,
>> > SpellingListIndex));
>> > }
>> >
>> > +/// Normalize the attribute, __foo__ becomes foo.
>> > +/// Returns true if normalization was applied.
>> > +static bool normalizeName(StringRef &AttrName) {
>> > +  if (AttrName.startswith("__") && AttrName.endswith("__")) {
>> > +assert(AttrName.size() > 4 && "Name too short");
>> 
>> 
>>  This assert will fire on the strings __, ___, and , which are
>> valid
>>  in
>>  some of the below cases.
>> >>>
>> >>> That assert won't fire on anything but  because it's &&, not ||.
>> >>
>> >>
>> >> I disagree. __ starts with __ and ends with __. The right thing to do
>> here
>> >> is remove the assert and put back the AttrName.size() > 4 check that
>> the
>> >> callers used to have.
>> >
>> > Hah, you are correct. I hadn't considered that point. I agree with you.
>> :-)
>> >
>> > ~Aaron
>> >
>> >>
>> >>> I
>> >>> don't think these names were intended to be valid in their uses.
>> >>> However, you are correct that this will trigger assertions instead of
>> >>> diagnostics. Adrian, can you investigate?
>> >>>
>> 
>> >
>> > +AttrName = AttrName.drop_front(2).drop_back(2);
>> > +return true;
>> > +  }
>> > +  return false;
>> > +}
>> > +
>> > static void handleOwnershipAttr(Sema &S, Decl *D, const
>> AttributeList
>> > &AL) {
>> >   // This attribute must be applied to a function declaration. The
>> > first
>> >   // argument to the attribute must be an identifier, the name of
>> the
>> > resource,
>> > @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,
>> >
>> >   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
>> >
>> > -  // Normalize the argument, __foo__ becomes foo.
>> >   StringRef ModuleName = Module->getName();
>> > -  if (ModuleName.startswith("__") && ModuleName.endswith("__") &&
>> > -  ModuleName.size() > 4) {
>> > -ModuleName = 

Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-08 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 36897.
beanz added a comment.

Updates to fix dependency mapping.

Compiler-rt will be cleaned and rebuilt if clang changes and reconfigured if 
llvm-config or clang changes.


http://reviews.llvm.org/D13399

Files:
  runtime/CMakeLists.txt

Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -24,85 +24,101 @@
 
 set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
-  if(CMAKE_GENERATOR MATCHES "Ninja")
-message(FATAL_ERROR
-"Ninja generator can't build compiler-rt as ExternalProject."
-"Unset LLVM_BUILD_EXTERNAL_COMPILER_RT, or don't use Ninja."
-"See http://www.cmake.org/Bug/view.php?id=14771";)
+  if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
+set(cmake_3_4_USES_TERMINAL_OPTIONS
+  USES_TERMINAL_CONFIGURE 1
+  USES_TERMINAL_BUILD 1
+  USES_TERMINAL_INSTALL 1
+  )
   endif()
 
   # Add compiler-rt as an external project.
   set(COMPILER_RT_PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt)
-  
+
+  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-stamps/)
+  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-bins/)
+
+  add_custom_target(compiler-rt-clear
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
+COMMENT "Clobberring compiler-rt build and stamp directories"
+)
+
   ExternalProject_Add(compiler-rt
 PREFIX ${COMPILER_RT_PREFIX}
 SOURCE_DIR ${COMPILER_RT_SRC_ROOT}
-CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+STAMP_DIR ${STAMP_DIR}
+BINARY_DIR ${BINARY_DIR}
+CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
+   -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
-   -DCMAKE_BUILD_TYPE=Release
+   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
-DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
-   -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
+   -DCOMPILER_RT_INSTALL_PATH=${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-   -DCOMPILER_RT_ENABLE_WERROR=ON
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
+${cmake_3_4_USES_TERMINAL_OPTIONS}
 )
-  # Due to a bug, DEPENDS in ExternalProject_Add doesn't work
-  # in CMake 2.8.9 and 2.8.10.
-  add_dependencies(compiler-rt llvm-config clang)
-
-  # Add a custom step to always re-configure compiler-rt (in case some of its
-  # sources have changed).
-  ExternalProject_Add_Step(compiler-rt force-reconfigure
-DEPENDERS configure
-ALWAYS 1
+
+  get_ext_project_build_command(run_clean_compiler_rt clean)
+  ExternalProject_Add_Step(compiler-rt clean
+COMMAND ${run_clean_compiler_rt}
+COMMENT "Cleaning compiler-rt..."
+DEPENDEES configure
+DEPENDERS build
+DEPENDS clang
+WORKING_DIRECTORY ${BINARY_DIR}
 )
 
-  ExternalProject_Add_Step(compiler-rt clobber
-COMMAND ${CMAKE_COMMAND} -E remove_directory 
-COMMAND ${CMAKE_COMMAND} -E make_directory 
-COMMENT "Clobberring compiler-rt build directory..."
-DEPENDERS configure
-DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-  )
+  add_dependencies(compiler-rt-configure clang llvm-config)
 
-  ExternalProject_Get_Property(compiler-rt BINARY_DIR)
-  set(COMPILER_RT_BINARY_DIR ${BINARY_DIR})
+  install(CODE "execute_process\(COMMAND ${CMAKE_COMMAND} -P ${BINARY_DIR}/cmake_install.cmake \)"
+COMPONENT compiler-rt)
+
+  add_custom_target(install-compiler-rt
+DEPENDS compiler-rt
+COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=compiler-rt
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan)
   foreach(runtime ${COMPILER_RT_RUNTIMES})
 get_ext_project_build_command(build_runtime_cmd ${runtime})
 add_custom_target(${runtime}
   COMMAND ${build_runtime_cmd}
   DEPENDS compiler-rt-configure
-  WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR}
+  WORKING_DIRECTORY ${BINARY_DIR}
   VERBATIM)
   endforeach()
 
-  # Add binaries that compiler-rt tests depend on.
-  set(COMPILER_RT_TEST_DEPENDENCIES
-FileCheck count not llvm-nm llvm-symbolizer)
-
-  # Add top-level targets fo

Re: [PATCH] D13304: Avoid inlining in throw statement

2015-10-08 Thread via cfe-commits

Yes, these are functionally equivalent. However, the difference between
these two is that the call to f() in 1st is in sub-expression of throw
statement, while the call in 2nd is not.
If the call is in the sub-expression of throw statements, we can guarantee
that the call is only invoked to be thrown. I just wanted to chase this
clear case.



> On Thu, Oct 8, 2015 at 9:54 AM,  wrote:
>
>> > I think this actually makes it less general. You would presumably
>> perform
>> > different inlining for:
>> >
>> >   throw f(x, y);
>> >
>> > versus
>> >
>> >   auto k = f(x, y);
>> >   throw k;
>>
>> We need to differentiate between these two. For the second case, we
>> should
>> not add any attribute because it’s not invoked in the EH region and it
>> could have any other purposes other than exception handling. I believe
>> we
>> need to specifically handle only the case where we can guarantee that
>> the
>> call is invoked only in exception handling context.
>
>
> Modulo copying the value returned by f, those two are equivalent, and it's
> entirely reasonable to want to refactor one into the other. Such
> refactoring should not affect the optimizer's behavior on this code. Why
> do
> you think they should be treated differently?
>


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


  1   2   >