r261195 - [MSVC] Turn C++ EH on my default

2016-02-18 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Thu Feb 18 02:15:05 2016
New Revision: 261195

URL: http://llvm.org/viewvc/llvm-project?rev=261195&view=rev
Log:
[MSVC] Turn C++ EH on my default

Our support for C++ EH is sufficiently good that it makes sense to
enable support for it out of the box.

While we are here, update the MSVCCompatibility doc.

Modified:
cfe/trunk/docs/MSVCCompatibility.rst
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/docs/MSVCCompatibility.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/MSVCCompatibility.rst?rev=261195&r1=261194&r2=261195&view=diff
==
--- cfe/trunk/docs/MSVCCompatibility.rst (original)
+++ cfe/trunk/docs/MSVCCompatibility.rst Thu Feb 18 02:15:05 2016
@@ -84,18 +84,23 @@ The status of major ABI-impacting C++ fe
 * RTTI: :good:`Complete`.  Generation of RTTI data structures has been
   finished, along with support for the ``/GR`` flag.
 
-* Exceptions and SEH: :partial:`Partial`.
-  C++ exceptions (``try`` / ``catch`` / ``throw``) and
-  structured exceptions (``__try`` / ``__except`` / ``__finally``) mostly
-  work on x64. 32-bit exception handling support is being worked on.  LLVM does
-  not model asynchronous exceptions, so it is currently impossible to catch an
-  asynchronous exception generated in the same frame as the catching ``__try``.
+* C++ Exceptions: :good:`Mostly complete`.  Support for
+  C++ exceptions (``try`` / ``catch`` / ``throw``) have been implemented for
+  x86 and x64.  Our implementation has been well tested but we still get the
+  odd bug report now and again.
   C++ exception specifications are ignored, but this is `consistent with Visual
   C++`_.
 
 .. _consistent with Visual C++:
   https://msdn.microsoft.com/en-us/library/wfa0edys.aspx
 
+* Asynchronous Exceptions (SEH): :partial:`Partial`.
+  Structured exceptions (``__try`` / ``__except`` / ``__finally``) mostly
+  work on x86 and x64.
+  LLVM does not model asynchronous exceptions, so it is currently impossible to
+  catch an asynchronous exception generated in the same frame as the catching
+  ``__try``.
+
 * Thread-safe initialization of local statics: :good:`Complete`.  MSVC 2015
   added support for thread-safe initialization of such variables by taking an
   ABI break.

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261195&r1=261194&r2=261195&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Feb 18 02:15:05 2016
@@ -2410,11 +2410,9 @@ static void addExceptionArgs(const ArgLi
   }
 
   if (types::isCXX(InputType)) {
-// Disable C++ EH by default on XCore, PS4, and MSVC.
-// FIXME: Remove MSVC from this list once things work.
-bool CXXExceptionsEnabled = Triple.getArch() != llvm::Triple::xcore &&
-!Triple.isPS4CPU() &&
-!Triple.isWindowsMSVCEnvironment();
+// Disable C++ EH by default on XCore and PS4.
+bool CXXExceptionsEnabled =
+Triple.getArch() != llvm::Triple::xcore && !Triple.isPS4CPU();
 Arg *ExceptionArg = Args.getLastArg(
 options::OPT_fcxx_exceptions, options::OPT_fno_cxx_exceptions,
 options::OPT_fexceptions, options::OPT_fno_exceptions);


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


r261196 - [CLANG] [AVX512] [BUILTIN] Adding pmovsx{b|d|w}{w|d|q}{128|256|512} builtin to clang

2016-02-18 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu Feb 18 03:09:34 2016
New Revision: 261196

URL: http://llvm.org/viewvc/llvm-project?rev=261196&view=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding pmovsx{b|d|w}{w|d|q}{128|256|512} builtin to 
clang 

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=261196&r1=261195&r2=261196&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Feb 18 03:09:34 2016
@@ -1572,6 +1572,24 @@ TARGET_BUILTIN(__builtin_ia32_rangepd512
 TARGET_BUILTIN(__builtin_ia32_rangeps512_mask, "V16fV16fV16fIiV16fUsIi", "", 
"avx512dq")
 TARGET_BUILTIN(__builtin_ia32_reducepd512_mask, "V8dV8dIiV8dUcIi", "", 
"avx512dq")
 TARGET_BUILTIN(__builtin_ia32_reduceps512_mask, "V16fV16fIiV16fUsIi", "", 
"avx512dq")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbw512_mask, "V32sV32cV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbd512_mask, "V16iV16cV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbq512_mask, 
"V8LLiV16cV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsxdq512_mask, "V8LLiV8iV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsxwd512_mask, "V16iV16sV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsxwq512_mask, "V8LLiV8sV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbw128_mask, 
"V8sV16cV8sUc","","avx512vl,avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbw256_mask, 
"V16sV16cV16sUs","","avx512vl,avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbd128_mask, "V4iV16cV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbd256_mask, "V8iV16cV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbq128_mask, 
"V2LLiV16cV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxbq256_mask, 
"V4LLiV16cV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxdq128_mask, 
"V2LLiV4iV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxdq256_mask, 
"V4LLiV4iV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxwd128_mask, "V4iV8sV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxwd256_mask, "V8iV8sV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxwq128_mask, 
"V2LLiV8sV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsxwq256_mask, 
"V4LLiV8sV4LLiUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=261196&r1=261195&r2=261196&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Thu Feb 18 03:09:34 2016
@@ -1496,6 +1496,32 @@ _mm512_maskz_unpacklo_epi16 (__mmask32 _
  (__mmask32) __U);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_cvtepi8_epi16 (__m256i __A)
+{
+  return (__m512i) __builtin_ia32_pmovsxbw512_mask ((__v32qi) __A,
+(__v32hi)
+_mm512_setzero_hi (),
+(__mmask32) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_cvtepi8_epi16 (__m512i __W, __mmask32 __U, __m256i __A)
+{
+  return (__m512i) __builtin_ia32_pmovsxbw512_mask ((__v32qi) __A,
+(__v32hi) __W,
+(__mmask32) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtepi8_epi16 (__mmask32 __U, __m256i __A)
+{
+  return (__m512i) __builtin_ia32_pmovsxbw512_mask ((__v32qi) __A,
+(__v32hi)
+_mm512_setzero_hi(),
+(__mmask32) __U);
+}
+
 #define _mm512_cmp_epi8_mask(a, b, p) __extension__ ({ \
   (__mmask16)__builtin_ia32_cmpb512_mask((__v64qi)(__m512i)(a), \
  (__v64qi)(__m512i)(b), \

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=261196&r1=261195&r2=261196&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Feb 18 03:09:34 2016
@@ -3029,6 +3029,136 @@ _mm512_mask_cmpneq_epu64_mask(__mmask8 _
 __u);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_cvtepi8_epi32 (__m128i __A)
+{
+  

Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-02-18 Thread Xiuli PAN via cfe-commits
pxli168 planned changes to this revision.
pxli168 added a comment.

It seems it is related with the pipe type. I am still working on how to fix 
this problem.


http://reviews.llvm.org/D16040



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


Re: [PATCH] D17149: Consolidate and improve the handling of built-in feature-like macros

2016-02-18 Thread Andy Gibbs via cfe-commits
AndyG added a comment.

Bump :o)


http://reviews.llvm.org/D17149



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


Re: [PATCH] D17330: PR26648: "inline" shouldn't be recognized as a C keyword in MSVC 2013 compatibility mode

2016-02-18 Thread Andrey Bokhanko via cfe-commits
andreybokhanko abandoned this revision.
andreybokhanko added a comment.

@rnk, fair enough. OK, please consider this review request dropped.

Andrey


http://reviews.llvm.org/D17330



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


r261204 - [analyzer] Add --force-analyze-debug-code option to scan-build

2016-02-18 Thread Yury Gribov via cfe-commits
Author: ygribov
Date: Thu Feb 18 05:08:46 2016
New Revision: 261204

URL: http://llvm.org/viewvc/llvm-project?rev=261204&view=rev
Log:
[analyzer] Add --force-analyze-debug-code option to scan-build
to force debug build and hopefully enable more precise warnings.

Static Analyzer is much more efficient when built in debug mode
(-UNDEBUG) so we advice users to enable it manually. This may be
inconvenient in case of large complex projects (think about Linux
distros e.g. Android or Tizen). This patch adds a flag to scan-build
which inserts -UNDEBUG automatically.

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

Modified:
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
cfe/trunk/tools/scan-build/bin/scan-build
cfe/trunk/tools/scan-build/libexec/ccc-analyzer
cfe/trunk/www/analyzer/scan-build.html

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py?rev=261204&r1=261203&r2=261204&view=diff
==
--- cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py Thu Feb 18 05:08:46 
2016
@@ -106,7 +106,8 @@ def run_analyzer(args, output_dir):
 'output_dir': output_dir,
 'output_format': args.output_format,
 'output_failures': args.output_failures,
-'direct_args': analyzer_params(args)
+'direct_args': analyzer_params(args),
+'force_analyze_debug_code' : args.force_analyze_debug_code
 }
 
 logging.debug('run analyzer against compilation database')
@@ -138,7 +139,9 @@ def setup_environment(args, destination,
 'ANALYZE_BUILD_REPORT_DIR': destination,
 'ANALYZE_BUILD_REPORT_FORMAT': args.output_format,
 'ANALYZE_BUILD_REPORT_FAILURES': 'yes' if args.output_failures else '',
-'ANALYZE_BUILD_PARAMETERS': ' '.join(analyzer_params(args))
+'ANALYZE_BUILD_PARAMETERS': ' '.join(analyzer_params(args)),
+'ANALYZE_BUILD_FORCE_ANALYZE_DEBUG_CODE'
+: 'yes' if args.force_analyze_debug_code else ''
 })
 return environment
 
@@ -168,6 +171,8 @@ def analyze_build_wrapper(cplusplus):
 'output_failures': os.getenv('ANALYZE_BUILD_REPORT_FAILURES'),
 'direct_args': os.getenv('ANALYZE_BUILD_PARAMETERS',
  '').split(' '),
+'force_analyze_debug_code':
+os.getenv('ANALYZE_BUILD_FORCE_ANALYZE_DEBUG_CODE'),
 'directory': os.getcwd(),
 }
 # get relevant parameters from command line arguments
@@ -450,6 +455,13 @@ def create_parser(from_build_command):
 Could be usefull when project contains 3rd party libraries.
 The directory path shall be absolute path as file names in
 the compilation database.""")
+advanced.add_argument(
+'--force-analyze-debug-code',
+dest='force_analyze_debug_code',
+action='store_true',
+help="""Tells analyzer to enable assertions in code even if they were
+disabled during compilation, enabling more precise
+results.""")
 
 plugins = parser.add_argument_group('checker options')
 plugins.add_argument(

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/runner.py?rev=261204&r1=261203&r2=261204&view=diff
==
--- cfe/trunk/tools/scan-build-py/libscanbuild/runner.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/runner.py Thu Feb 18 05:08:46 
2016
@@ -41,6 +41,7 @@ def require(required):
 
 @require(['command', 'directory', 'file',  # an entry from compilation database
   'clang', 'direct_args',  # compiler name, and arguments from command
+  'force_analyze_debug_code',  # preprocessing options
   'output_dir', 'output_format', 'output_failures'])
 def run(opts):
 """ Entry point to run (or not) static analyzer against a single entry
@@ -164,9 +165,13 @@ def set_analyzer_output(opts, continuati
 opts.update({'output': ['-o', opts['output_dir']]})
 return continuation(opts)
 
-
-@require(['file', 'directory', 'clang', 'direct_args', 'language',
-  'output_dir', 'output_format', 'output_failures'])
+def force_analyze_debug_code(cmd):
+""" Enable assert()'s by undefining NDEBUG. """
+cmd.append('-UNDEBUG')
+
+@require(['file', 'directory', 'clang', 'direct_args',
+  'force_analyze_debug_code', 'language', 'output_dir',
+  'output_format', 'output_failures'])
 def create_commands(opts, continuation=set_analyzer_output):
 """ Create comman

Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-02-18 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3901-3932
@@ +3900,34 @@
+// Reference types are ignored for mapping purposes.
+if (auto *RefTy = ExprTy->getAs())
+  ExprTy = RefTy->getPointeeType().getCanonicalType();
+
+// Given that an array section is considered a built-in type, we need to
+// do the calculation based on the length of the section instead of relying
+// on CGF.getTypeSize(E->getType()).
+if (const auto *OAE = dyn_cast(E)) {
+  auto BaseTy =
+  OAE->getBase()->IgnoreParenImpCasts()->getType().getCanonicalType();
+  // Reference types are ignored for mapping purposes.
+  if (auto *RefTy = BaseTy->getAs())
+BaseTy = RefTy->getPointeeType().getCanonicalType();
+
+  // If there is no length associated with the expression, that means we
+  // are using the whole length of the base.
+  if (!OAE->getLength())
+return CGF.getTypeSize(BaseTy);
+
+  llvm::Value *ElemSize;
+  if (auto *PTy = BaseTy->getAs()) {
+ElemSize = CGF.getTypeSize(PTy->getPointeeType().getCanonicalType());
+  } else {
+auto *ATy = cast(BaseTy.getTypePtr());
+assert(ATy && "Expecting array type if not a pointer type.");
+ElemSize = CGF.getTypeSize(ATy->getElementType().getCanonicalType());
+  }
+
+  auto *LengthVal = CGF.EmitScalarExpr(OAE->getLength());
+  LengthVal =
+  CGF.Builder.CreateIntCast(LengthVal, CGF.SizeTy, /*isSigned=*/false);
+  return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
+}
+return CGF.getTypeSize(ExprTy);

Did not find any with array sections as base. Could please point a test where I 
can find something like 'marr[:][0:2][0:2]' as a mapped expression?
Also, it will produce some recalculation for VLAs. Add a test for it, please.


http://reviews.llvm.org/D16749



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


[PATCH] D17375: Add parentheses around arithmetic in operand of '|' in llvm-dwp.cpp.

2016-02-18 Thread Cong Liu via cfe-commits
congliu created this revision.
congliu added a reviewer: bkramer.
congliu added a subscriber: cfe-commits.

Add the parenthese to make it able to build.

http://reviews.llvm.org/D17375

Files:
  tools/llvm-dwp/llvm-dwp.cpp

Index: tools/llvm-dwp/llvm-dwp.cpp
===
--- tools/llvm-dwp/llvm-dwp.cpp
+++ tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@
 while (Buckets[H]) {
   assert(S != IndexEntries[Buckets[H] - 1].Signature &&
  "Duplicate type unit");
-  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+  H = ((H + ((S >> 32) & Mask)) | 1) % Buckets.size();
 }
 Buckets[H] = i + 1;
   }


Index: tools/llvm-dwp/llvm-dwp.cpp
===
--- tools/llvm-dwp/llvm-dwp.cpp
+++ tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@
 while (Buckets[H]) {
   assert(S != IndexEntries[Buckets[H] - 1].Signature &&
  "Duplicate type unit");
-  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+  H = ((H + ((S >> 32) & Mask)) | 1) % Buckets.size();
 }
 Buckets[H] = i + 1;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17375: Add parentheses around arithmetic in operand of '|' in llvm-dwp.cpp.

2016-02-18 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

I think this is the wrong solution. Per 
http://www.dwarfstd.org/ShowIssue.php?issue=140421.1

  2.  Calculate a secondary hash H' = (((S >> 32) & MASK(k)) | 1).
  [...]
  4.  Let H = (H + H') modulo M. Repeat at Step 3.

So the OR has to happen before the ADD.


http://reviews.llvm.org/D17375



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


Re: [PATCH] D17375: Add parentheses around arithmetic in operand of '|' in llvm-dwp.cpp.

2016-02-18 Thread Cong Liu via cfe-commits
congliu updated this revision to Diff 48301.
congliu added a comment.

- Address review comment.


http://reviews.llvm.org/D17375

Files:
  tools/llvm-dwp/llvm-dwp.cpp

Index: tools/llvm-dwp/llvm-dwp.cpp
===
--- tools/llvm-dwp/llvm-dwp.cpp
+++ tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@
 while (Buckets[H]) {
   assert(S != IndexEntries[Buckets[H] - 1].Signature &&
  "Duplicate type unit");
-  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+  H = (H + (((S >> 32) & Mask) | 1)) % Buckets.size();
 }
 Buckets[H] = i + 1;
   }


Index: tools/llvm-dwp/llvm-dwp.cpp
===
--- tools/llvm-dwp/llvm-dwp.cpp
+++ tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@
 while (Buckets[H]) {
   assert(S != IndexEntries[Buckets[H] - 1].Signature &&
  "Duplicate type unit");
-  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+  H = (H + (((S >> 32) & Mask) | 1)) % Buckets.size();
 }
 Buckets[H] = i + 1;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-02-18 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3799-3806
@@ -3780,4 +3798,10 @@
   OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// \brief Emit the num_teams clause of an enclosed teams directive at the
+/// target region scope. If there is no teams directive associated with the
+/// target directive, or if there is no num_teams clause associated with the
+/// enclosed teams directive, return nullptr.
+static llvm::Value *
+emitNumTeamsClauseForTargetDirective(CodeGenFunction &CGF,

I don't understand why global var is not captured in target region. If it is 
not implemented yet, it must be implemented. If it is not captured, it must be 
captured in Sema. We should not introduce some function/other objects to find a 
workaround for 'not implemented' features.


http://reviews.llvm.org/D17019



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


Re: [PATCH] D17375: Add parentheses around arithmetic in operand of '|' in llvm-dwp.cpp.

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

LGTM, will commit it for you.


http://reviews.llvm.org/D17375



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


Re: [PATCH] D17375: Add parentheses around arithmetic in operand of '|' in llvm-dwp.cpp.

2016-02-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261207: Add parentheses around arithmetic in operand of '|'. 
(authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D17375?vs=48301&id=48302#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17375

Files:
  llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@
 while (Buckets[H]) {
   assert(S != IndexEntries[Buckets[H] - 1].Signature &&
  "Duplicate type unit");
-  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+  H = (H + (((S >> 32) & Mask) | 1)) % Buckets.size();
 }
 Buckets[H] = i + 1;
   }


Index: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
@@ -238,7 +238,7 @@
 while (Buckets[H]) {
   assert(S != IndexEntries[Buckets[H] - 1].Signature &&
  "Duplicate type unit");
-  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
+  H = (H + (((S >> 32) & Mask) | 1)) % Buckets.size();
 }
 Buckets[H] = i + 1;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16139: [MIPS] initFeatureMap() to handle empty string argument

2016-02-18 Thread Bhushan Attarde via cfe-commits
bhushan added a comment.

This was observed during expression evaluation in LLDB, where LLDB does not 
explicitly set `clang::TargetOptions::CPU` hence it remains empty.


Repository:
  rL LLVM

http://reviews.llvm.org/D16139



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


Re: [PATCH] D17148: [OPENMP] Basic teams directive implementation

2016-02-18 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4426-4431
@@ +4425,8 @@
+ SourceLocation Loc) {
+  llvm::Value *PushNumTeamsArgs[] = {
+  emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc), NumTeams,
+  ThreadLimit};
+  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_push_num_teams),
+  PushNumTeamsArgs);
+
+  if (!CGF.HaveInsertPoint())

What is this? Copy-paste?


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4432-4433
@@ +4431,4 @@
+
+  if (!CGF.HaveInsertPoint())
+return;
+  // Build call __kmpc_push_num_threads(&loc, global_tid, num_threads)

This must be checked at the start of the function


Comment at: lib/CodeGen/CGOpenMPRuntime.h:997-1003
@@ +996,9 @@
+
+  /// \brief Emits call to void __kmpc_push_num_teamss(ident_t *loc, kmp_int32
+  /// global_tid, kmp_int32 num_teams, kmp_int32 thread_limit) to generate code
+  /// for num_teams clause.
+  /// \param NumTeams An integer value of teams.
+  /// \param ThreadsLimit An integer value of threads.
+  virtual void emitNumTeamsClause(CodeGenFunction &CGF, llvm::Value *NumTeams,
+  llvm::Value *ThreadLimit, SourceLocation 
Loc);
+

Ok, just missed it.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2724-2725
@@ +2723,4 @@
+  const OMPTeamsDirective &TD = *dyn_cast(&S);
+  llvm::Value *NumTeamsVal = nullptr;
+  llvm::Value *ThreadLimitVal = nullptr;
+

These vars must be declared inside 'if' stmt for clauses.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2758
@@ -2712,1 +2757,3 @@
+
+// TODO: deal with clauses other than num_teams and thread_limit
 

I don't think we need this comment now.


Repository:
  rL LLVM

http://reviews.llvm.org/D17148



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


Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-18 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:1876-1878
@@ +1875,5 @@
+  SourceLocation Loc,
+  OpenMPScheduleClauseKind ForSchedKind,
+  OpenMPDistScheduleClauseKind DistSchedKind,
+  bool isForSchedule,
+  unsigned IVSize, bool IVSigned, bool Ordered,

I think you can pass OpenMPSchedType here instead of OpenMPScheduleClauseKind  
and OpenMPDistScheduleClauseKind .


Comment at: lib/CodeGen/CGOpenMPRuntime.h:187-208
@@ -185,30 +186,24 @@
+
+public:
   /// \brief Values for bit flags used in the ident_t to describe the fields.
   /// All enumeric elements are named and described in accordance with the code
   /// from http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp.h
   enum OpenMPLocationFlags {
 /// \brief Use trampoline for internal microtask.
 OMP_IDENT_IMD = 0x01,
 /// \brief Use c-style ident structure.
 OMP_IDENT_KMPC = 0x02,
 /// \brief Atomic reduction option for kmpc_reduce.
 OMP_ATOMIC_REDUCE = 0x10,
 /// \brief Explicit 'barrier' directive.
 OMP_IDENT_BARRIER_EXPL = 0x20,
 /// \brief Implicit barrier in code.
 OMP_IDENT_BARRIER_IMPL = 0x40,
 /// \brief Implicit barrier in 'for' directive.
 OMP_IDENT_BARRIER_IMPL_FOR = 0x40,
 /// \brief Implicit barrier in 'sections' directive.
 OMP_IDENT_BARRIER_IMPL_SECTIONS = 0xC0,
 /// \brief Implicit barrier in 'single' directive.
 OMP_IDENT_BARRIER_IMPL_SINGLE = 0x140
   };
 

No, do not make it public. It must be private forever. Moreover, It would be 
good if could hide it at all in .cpp file. I will look at it.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:553-566
@@ -564,2 +552,16 @@
 
+  /// \brief Emits object of ident_t type with info for source location.
+  /// \param Flags Flags for OpenMP location.
+  ///
+  llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
+  OpenMPLocationFlags Flags = OMP_IDENT_KMPC);
+
+  /// \brief Gets thread id value for the current thread.
+  ///
+  llvm::Value *getThreadID(CodeGenFunction &CGF, SourceLocation Loc);
+
+  /// \brief Returns __kmpc_for_static_init_* runtime function for the 
specified
+  /// size \a IVSize and sign \a IVSigned.
+  llvm::Constant *createForStaticInitFunction(unsigned IVSize, bool IVSigned);
+
   /// \brief Emits outlined function for the specified OpenMP parallel 
directive

Keep them private, please


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:1892-1894
@@ -1853,4 +1891,5 @@
 // Emit static non-chunked loop.
-CGF.CGM.getOpenMPRuntime().emitForStaticInit(
-CGF, S.getLocStart(), OMPC_SCHEDULE_static, /*IVSize=*/32,
+CGF.CGM.getOpenMPRuntime().emitForStaticInit(CGF, S.getLocStart(),
+OMPC_SCHEDULE_static,
+/*IVSize=*/32,
 /*IVSigned=*/true, /*Ordered=*/false, IL.getAddress(), LB.getAddress(),

Revert it back, no actual changes


Comment at: lib/Serialization/ASTReaderStmt.cpp:2303
@@ -2303,1 +2302,3 @@
+  isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
+ isOpenMPDistributeDirective(D->getDirectiveKind())) {
 D->setIsLastIterVariable(Reader.ReadSubExpr());

Reformat it, please, indentation is wrong


Comment at: lib/Serialization/ASTWriterStmt.cpp:2091
@@ -2091,1 +2090,3 @@
+  isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
+ isOpenMPDistributeDirective(D->getDirectiveKind())) {
 Writer.AddStmt(D->getIsLastIterVariable());

Indentation


Repository:
  rL LLVM

http://reviews.llvm.org/D17170



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


r261209 - [OPENMP] Fix codegen for lastprivate loop counters.

2016-02-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Feb 18 07:48:15 2016
New Revision: 261209

URL: http://llvm.org/viewvc/llvm-project?rev=261209&view=rev
Log:
[OPENMP] Fix codegen for lastprivate loop counters.

Patch fixes bug with codegen for lastprivate loop counters. Also it may
improve performance for lastprivates calculations in some cases.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=261209&r1=261208&r2=261209&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Feb 18 07:48:15 2016
@@ -653,71 +653,48 @@ void CodeGenFunction::EmitOMPLastprivate
 EmitBlock(ThenBB);
   }
   llvm::DenseMap LoopCountersAndUpdates;
-  const Expr *LastIterVal = nullptr;
-  const Expr *IVExpr = nullptr;
-  const Expr *IncExpr = nullptr;
   if (auto *LoopDirective = dyn_cast(&D)) {
-if (isOpenMPWorksharingDirective(D.getDirectiveKind())) {
-  LastIterVal = cast(cast(
-  LoopDirective->getUpperBoundVariable())
-  ->getDecl())
-->getAnyInitializer();
-  IVExpr = LoopDirective->getIterationVariable();
-  IncExpr = LoopDirective->getInc();
-  auto IUpdate = LoopDirective->updates().begin();
-  for (auto *E : LoopDirective->counters()) {
-auto *D = cast(E)->getDecl()->getCanonicalDecl();
-LoopCountersAndUpdates[D] = *IUpdate;
-++IUpdate;
-  }
+auto IC = LoopDirective->counters().begin();
+for (auto F : LoopDirective->finals()) {
+  auto *D = cast(*IC)->getDecl()->getCanonicalDecl();
+  LoopCountersAndUpdates[D] = F;
+  ++IC;
 }
   }
-  {
-llvm::DenseSet AlreadyEmittedVars;
-bool FirstLCV = true;
-for (const auto *C : D.getClausesOfKind()) {
-  auto IRef = C->varlist_begin();
-  auto ISrcRef = C->source_exprs().begin();
-  auto IDestRef = C->destination_exprs().begin();
-  for (auto *AssignOp : C->assignment_ops()) {
-auto *PrivateVD = cast(cast(*IRef)->getDecl());
-QualType Type = PrivateVD->getType();
-auto *CanonicalVD = PrivateVD->getCanonicalDecl();
-if (AlreadyEmittedVars.insert(CanonicalVD).second) {
-  // If lastprivate variable is a loop control variable for loop-based
-  // directive, update its value before copyin back to original
-  // variable.
-  if (auto *UpExpr = LoopCountersAndUpdates.lookup(CanonicalVD)) {
-if (FirstLCV && LastIterVal) {
-  EmitAnyExprToMem(LastIterVal, EmitLValue(IVExpr).getAddress(),
-   IVExpr->getType().getQualifiers(),
-   /*IsInitializer=*/false);
-  EmitIgnoredExpr(IncExpr);
-  FirstLCV = false;
-}
-EmitIgnoredExpr(UpExpr);
-  }
-  auto *SrcVD = cast(cast(*ISrcRef)->getDecl());
-  auto *DestVD = 
cast(cast(*IDestRef)->getDecl());
-  // Get the address of the original variable.
-  Address OriginalAddr = GetAddrOfLocalVar(DestVD);
-  // Get the address of the private variable.
-  Address PrivateAddr = GetAddrOfLocalVar(PrivateVD);
-  if (auto RefTy = PrivateVD->getType()->getAs())
-PrivateAddr =
+  llvm::DenseSet AlreadyEmittedVars;
+  for (const auto *C : D.getClausesOfKind()) {
+auto IRef = C->varlist_begin();
+auto ISrcRef = C->source_exprs().begin();
+auto IDestRef = C->destination_exprs().begin();
+for (auto *AssignOp : C->assignment_ops()) {
+  auto *PrivateVD = cast(cast(*IRef)->getDecl());
+  QualType Type = PrivateVD->getType();
+  auto *CanonicalVD = PrivateVD->getCanonicalDecl();
+  if (AlreadyEmittedVars.insert(CanonicalVD).second) {
+// If lastprivate variable is a loop control variable for loop-based
+// directive, update its value before copyin back to original
+// variable.
+if (auto *UpExpr = LoopCountersAndUpdates.lookup(CanonicalVD))
+  EmitIgnoredExpr(UpExpr);
+auto *SrcVD = cast(cast(*ISrcRef)->getDecl());
+auto *DestVD = cast(cast(*IDestRef)->getDecl());
+// Get the address of the original variable.
+Address OriginalAddr = GetAddrOfLocalVar(DestVD);
+// Get the address of the private variable.
+Address PrivateAddr = GetAddrOfLocalVar(PrivateVD);
+if (auto RefTy = PrivateVD->getType()->getAs())
+  PrivateAddr =
   Address(Builder.CreateLoad(PrivateAddr),
   getNaturalTypeAlignment(RefTy->getPointeeType()));
-  EmitOMPCopy(Type, OriginalAddr, PrivateAddr, DestVD, SrcVD, 
AssignOp);
-}
-++IRef;
-++ISrcRef;
-

[PATCH] D17376: dump_ast_matchers.py: fix replacement regexps

2016-02-18 Thread Aleksei Sidorin via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: klimek, aaron.ballman.
a.sidorin added a subscriber: cfe-commits.
a.sidorin set the repository for this revision to rL LLVM.

Using re.sub() to replace a sample with '%'s looks strange and causes a format 
string error if a matcher description contains "%s". This patch resolves this 
issue.

Repository:
  rL LLVM

http://reviews.llvm.org/D17376

Files:
  docs/tools/dump_ast_matchers.py

Index: docs/tools/dump_ast_matchers.py
===
--- docs/tools/dump_ast_matchers.py
+++ docs/tools/dump_ast_matchers.py
@@ -363,11 +363,11 @@
 
 reference = open('../LibASTMatchersReference.html').read()
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % node_matcher_table
+   node_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % narrowing_matcher_table
+   narrowing_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % traversal_matcher_table
+   traversal_matcher_table, reference, flags=re.S)
 
 with open('../LibASTMatchersReference.html', 'wb') as output:
   output.write(reference)


Index: docs/tools/dump_ast_matchers.py
===
--- docs/tools/dump_ast_matchers.py
+++ docs/tools/dump_ast_matchers.py
@@ -363,11 +363,11 @@
 
 reference = open('../LibASTMatchersReference.html').read()
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % node_matcher_table
+   node_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % narrowing_matcher_table
+   narrowing_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % traversal_matcher_table
+   traversal_matcher_table, reference, flags=re.S)
 
 with open('../LibASTMatchersReference.html', 'wb') as output:
   output.write(reference)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-18 Thread Michael Matz via cfe-commits
Hi,

On Tue, 16 Feb 2016, H.J. Lu wrote:

> Here is the new definition:
> 
> An empty type is a type where it and all of its subobjects (recursively) 
> are of class, structure, union, or array type.  No memory slot nor 
> register should be used to pass or return an object of empty type.

The trivially copyable is gone again.  Why is it not necessary?


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


Re: [PATCH] D17376: dump_ast_matchers.py: fix replacement regexps

2016-02-18 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rL LLVM

http://reviews.llvm.org/D17376



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


[PATCH] D17378: Add additional Hi/Lo registers to Clang MipsTargetInfoBase

2016-02-18 Thread Hrvoje Varga via cfe-commits
hvarga created this revision.
hvarga added reviewers: hfinkel, atrick, chandlerc.
hvarga added subscribers: cfe-commits, petarj.

This patch fixes bug https://dmz-portal.mips.com/bugz/show_bug.cgi?id=2300 by 
adding additional (missing) Hi/Lo registers to the Clang `MipsTargetInfoBase` 
class.

http://reviews.llvm.org/D17378

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/mips-inline-asm.c

Index: test/CodeGen/mips-inline-asm.c
===
--- test/CodeGen/mips-inline-asm.c
+++ test/CodeGen/mips-inline-asm.c
@@ -17,3 +17,15 @@
   asm("lw $1, %0" :: "R"(data));
   // CHECK: call void asm sideeffect "lw $$1, $0", "*R,~{$1}"(i32* @data)
 }
+
+int additionalClobberedRegisters () {
+  int temp0;
+  asm volatile(
+"mfhi %[temp0], $ac1 \n\t"
+  : [temp0]"=&r"(temp0)
+  :
+  : "memory", "t0", "t1", "$ac1hi", "$ac1lo", "$ac2hi", 
"$ac2lo", "$ac3hi", "$ac3lo"
+  );
+  return 0;
+  // CHECK: call i32 asm sideeffect "mfhi $0, $$ac1 \0A\09", 
"=&r,~{memory},~{$8},~{$9},~{$ac1hi},~{$ac1lo},~{$ac2hi},~{$ac2lo},~{$ac3hi},~{$ac3lo},~{$1}"
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6678,7 +6678,8 @@
   "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",
   // Hi/lo and condition register names
   "hi",   "lo",   "", "$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",
-  "$fcc5","$fcc6","$fcc7",
+  "$fcc5","$fcc6","$fcc7","$ac1hi","$ac1lo","$ac2hi","$ac2lo",
+  "$ac3hi","$ac3lo",
   // MSA register names
   "$w0",  "$w1",  "$w2",  "$w3",  "$w4",  "$w5",  "$w6",  "$w7",
   "$w8",  "$w9",  "$w10", "$w11", "$w12", "$w13", "$w14", "$w15",


Index: test/CodeGen/mips-inline-asm.c
===
--- test/CodeGen/mips-inline-asm.c
+++ test/CodeGen/mips-inline-asm.c
@@ -17,3 +17,15 @@
   asm("lw $1, %0" :: "R"(data));
   // CHECK: call void asm sideeffect "lw $$1, $0", "*R,~{$1}"(i32* @data)
 }
+
+int additionalClobberedRegisters () {
+  int temp0;
+  asm volatile(
+"mfhi %[temp0], $ac1 \n\t"
+  : [temp0]"=&r"(temp0)
+  :
+  : "memory", "t0", "t1", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo"
+  );
+  return 0;
+  // CHECK: call i32 asm sideeffect "mfhi $0, $$ac1 \0A\09", "=&r,~{memory},~{$8},~{$9},~{$ac1hi},~{$ac1lo},~{$ac2hi},~{$ac2lo},~{$ac3hi},~{$ac3lo},~{$1}"
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6678,7 +6678,8 @@
   "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",
   // Hi/lo and condition register names
   "hi",   "lo",   "", "$fcc0","$fcc1","$fcc2","$fcc3","$fcc4",
-  "$fcc5","$fcc6","$fcc7",
+  "$fcc5","$fcc6","$fcc7","$ac1hi","$ac1lo","$ac2hi","$ac2lo",
+  "$ac3hi","$ac3lo",
   // MSA register names
   "$w0",  "$w1",  "$w2",  "$w3",  "$w4",  "$w5",  "$w6",  "$w7",
   "$w8",  "$w9",  "$w10", "$w11", "$w12", "$w13", "$w14", "$w15",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17378: Add additional Hi/Lo registers to Clang MipsTargetInfoBase

2016-02-18 Thread Hrvoje Varga via cfe-commits
hvarga added a comment.

I'm not sure if I added all of the necessary reviewers or even the correct 
ones. So please feel free to correct this if it's wrong.


http://reviews.llvm.org/D17378



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


Re: r261163 - Add 'nopartial' qualifier for availability attributes.

2016-02-18 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Feb-17, at 14:05, Manman Ren via cfe-commits 
>  wrote:
> 
> Author: mren
> Date: Wed Feb 17 16:05:48 2016
> New Revision: 261163
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=261163&view=rev
> Log:
> Add 'nopartial' qualifier for availability attributes.
> 
> An optional nopartial can be placed after the platform name.
> int bar() __attribute__((availability(macosx,nopartial,introduced=10.12))
> 
> When deploying back to a platform version prior to when the declaration was
> introduced, with 'nopartial', Clang emits an error specifying that the 
> function
> is not introduced yet; without 'nopartial', the behavior stays the same: the
> declaration is `weakly linked`.
> 
> A member is added to the end of AttributeList to save the location of the
> 'nopartial' keyword. A bool member is added to AvailabilityAttr.
> 
> The diagnostics for 'nopartial' not-yet-introduced is handled in the same way 
> as
> we handle unavailable cases.
> 
> Reviewed by Doug Gregor and Jordan Rose.
> 
> rdar://23791325
> 
> Modified:
>cfe/trunk/include/clang/Basic/Attr.td
>cfe/trunk/include/clang/Basic/AttrDocs.td
>cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>cfe/trunk/include/clang/Parse/Parser.h
>cfe/trunk/include/clang/Sema/AttributeList.h
>cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
>cfe/trunk/include/clang/Sema/Sema.h
>cfe/trunk/lib/Parse/ParseDecl.cpp
>cfe/trunk/lib/Parse/Parser.cpp
>cfe/trunk/lib/Sema/DelayedDiagnostic.cpp
>cfe/trunk/lib/Sema/SemaDecl.cpp
>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>cfe/trunk/lib/Sema/SemaExpr.cpp
>cfe/trunk/test/Sema/attr-availability-macosx.c
> 
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=261163&r1=261162&r2=261163&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Feb 17 16:05:48 2016
> @@ -450,7 +450,8 @@ def Availability : InheritableAttr {
>   let Spellings = [GNU<"availability">];
>   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
>   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
> -  BoolArgument<"unavailable">, StringArgument<"message">];
> +  BoolArgument<"unavailable">, StringArgument<"message">,
> +  BoolArgument<"nopartial">];
>   let AdditionalMembers =
> [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
> return llvm::StringSwitch(Platform)
> 
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=261163&r1=261162&r2=261163&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Feb 17 16:05:48 2016
> @@ -685,9 +685,14 @@ are:
>   Apple's watchOS operating system.  The minimum deployment target is 
> specified by
>   the ``-mwatchos-version-min=*version*`` command-line argument.
> 
> -A declaration can be used even when deploying back to a platform version 
> prior
> -to when the declaration was introduced.  When this happens, the declaration 
> is
> -`weakly linked
> +An optional nopartial

This should really be "``nopartial``" (code-quotes).  However, I have
a more substantial edit below.

> can be placed after the platform name.
> +With the optional nopartial, when deploying back to a platform version prior 
> to
> +when the declaration was introduced, Clang emits an error specifying that the
> +function is not introduced yet.
> +
> +Without the optional nopartial, a declaration can be used even when 
> deploying back
> +to a platform version prior to when the declaration was introduced.

I'd rather de-emphasize the new flag.  We're not expecting much adoption of
it (just libc++), so we should keep the text focused on describing the
default behaviour.  I suggest leaving the wording more like the original:
```
A declaration can typically be used even when deploying back to a platform
version prior to when the declaration was introduced.  When this happens,
the declaration is -`weakly linked
. . .
```
^ I've just added the word "typically".

Later, add a paragraph:
```
The flag ``flag-name`` disallows using API when deploying back to a
platform version prior to when the declaration was introduced.  An
attempt to use such API before its introduction causes a hard error.
Weakly-linking is almost always a better API choice, since it allows
users to query availability at runtime.
```

I'm also not sure about "nopartial" (my fault, this name was my idea).
In the context of all the text we have about availability (here, and
in the errors and notes) I think "strict" fi

r261217 - [Parse] Code complete expressions in bracket declarators.

2016-02-18 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Feb 18 09:30:24 2016
New Revision: 261217

URL: http://llvm.org/viewvc/llvm-project?rev=261217&view=rev
Log:
[Parse] Code complete expressions in bracket declarators.

Currently we return no results when completing inside of the brackets in
a 'char foo[]' declaration. Let the generic expression completion code
handle it instead. We could get fancier here (e.g. filter non-constant
expressions in contexts where VLAs are not allowed), but it's a strict
improvement over the existing version.

Added:
cfe/trunk/test/CodeCompletion/bracket-decl.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=261217&r1=261216&r2=261217&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 18 09:30:24 2016
@@ -8922,6 +8922,7 @@ public:
   void CodeCompletePostfixExpression(Scope *S, ExprResult LHS);
   void CodeCompleteTag(Scope *S, unsigned TagSpec);
   void CodeCompleteTypeQualifiers(DeclSpec &DS);
+  void CodeCompleteBracketDeclarator(Scope *S);
   void CodeCompleteCase(Scope *S);
   void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef Args);
   void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=261217&r1=261216&r2=261217&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Feb 18 09:30:24 2016
@@ -6030,6 +6030,9 @@ void Parser::ParseBracketDeclarator(Decl
 T.getCloseLocation()),
   attrs, T.getCloseLocation());
 return;
+  } else if (Tok.getKind() == tok::code_completion) {
+Actions.CodeCompleteBracketDeclarator(getCurScope());
+return cutOffParsing();
   }
 
   // If valid, this location is the position where we read the 'static' 
keyword.

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=261217&r1=261216&r2=261217&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Feb 18 09:30:24 2016
@@ -3818,6 +3818,10 @@ void Sema::CodeCompleteTypeQualifiers(De
 Results.data(), Results.size());
 }
 
+void Sema::CodeCompleteBracketDeclarator(Scope *S) {
+  CodeCompleteExpression(S, QualType(getASTContext().getSizeType()));
+}
+
 void Sema::CodeCompleteCase(Scope *S) {
   if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
 return;

Added: cfe/trunk/test/CodeCompletion/bracket-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/bracket-decl.c?rev=261217&view=auto
==
--- cfe/trunk/test/CodeCompletion/bracket-decl.c (added)
+++ cfe/trunk/test/CodeCompletion/bracket-decl.c Thu Feb 18 09:30:24 2016
@@ -0,0 +1,9 @@
+#define PATHSIZE 256
+
+static const int len = 1234;
+
+void foo() {
+  char arr[
+// RUN: %clang_cc1 -fsyntax-only -code-completion-macros 
-code-completion-at=%s:6:12 %s -o - | FileCheck %s
+// CHECK: COMPLETION: len
+// CHECK: COMPLETION: PATHSIZE


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


[PATCH] D17380: [libcxx] Split locale management out of ibm/xlocale.h. NFCI

2016-02-18 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: howard.hinnant, mclow.lists.
bcraig added a subscriber: cfe-commits.

This is one part of many of a locale refactor.  See 
http://reviews.llvm.org/D17146 for an idea of where this is going.

For the locale refactor, the locale management functions (newlocale, 
freelocale, uselocale) are needed in a separate header from the various _l 
functions.  This is because some platforms implement the _l functions in terms 
of a locale switcher RAII helper, and the locale switcher RAII helper needs the 
locale management functions.  This patch helps pave the way by getting all the 
functions in the right files, so that later diffs aren't completely horrible.

Unfortunately, I have no access to an AIX machine to build with, so this change 
has been made blind.  Also, the original author (Xing Xue) does not appear to 
have a Phabricator account.

http://reviews.llvm.org/D17380

Files:
  include/support/ibm/locale_mgmt_aix.h
  include/support/ibm/xlocale.h

Index: include/support/ibm/xlocale.h
===
--- include/support/ibm/xlocale.h
+++ include/support/ibm/xlocale.h
@@ -10,6 +10,7 @@
 
 #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
 #define _LIBCPP_SUPPORT_IBM_XLOCALE_H
+#include 
 
 #if defined(_AIX)
 #include "cstdlib"
@@ -21,62 +22,6 @@
 #if !defined(_AIX71)
 // AIX 7.1 and higher has these definitions.  Definitions and stubs
 // are provied here as a temporary workaround on AIX 6.1.
-
-#define LC_COLLATE_MASK 1
-#define LC_CTYPE_MASK   2
-#define LC_MESSAGES_MASK4
-#define LC_MONETARY_MASK8
-#define LC_NUMERIC_MASK 16
-#define LC_TIME_MASK32
-#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \
- LC_MESSAGES_MASK | LC_MONETARY_MASK |\
- LC_NUMERIC_MASK | LC_TIME_MASK)
-
-typedef void* locale_t;
-
-// The following are stubs.  They are not supported on AIX 6.1.
-static inline
-locale_t newlocale(int category_mask, const char *locale, locale_t base)
-{
-  _LC_locale_t *newloc, *loc;
-  if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL)
-  {
-errno = EINVAL;
-return (locale_t)0;
-  }
-  if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL)
-  {
-errno = ENOMEM;
-return (locale_t)0;
-  }
-  if (!base)
-base = (_LC_locale_t *)__xopen_locale("C");
-  memcpy(newloc, base, sizeof (_LC_locale_t));
-  if (category_mask & LC_COLLATE_MASK) 
-newloc->lc_collate = loc->lc_collate;
-  if (category_mask & LC_CTYPE_MASK)
-newloc->lc_ctype = loc->lc_ctype;
-  //if (category_mask & LC_MESSAGES_MASK)
-  //  newloc->lc_messages = loc->lc_messages;
-  if (category_mask & LC_MONETARY_MASK)
-newloc->lc_monetary = loc->lc_monetary;
-  if (category_mask & LC_TIME_MASK)
-newloc->lc_time = loc->lc_time;
-  if (category_mask & LC_NUMERIC_MASK)
-newloc->lc_numeric = loc->lc_numeric;
-  return (locale_t)newloc; 
-}
-static inline
-void freelocale(locale_t locobj)
-{
-  free(locobj);
-}
-static inline
-locale_t uselocale(locale_t newloc)
-{
-  return (locale_t)0;
-}
-
 static inline
 int isalnum_l(int c, locale_t locale)
 {
Index: include/support/ibm/locale_mgmt_aix.h
===
--- /dev/null
+++ include/support/ibm/locale_mgmt_aix.h
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+//===--- support/ibm/locale_mgmt_aix.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
+#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
+
+#if defined(_AIX)
+#include "cstdlib"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_AIX71)
+// AIX 7.1 and higher has these definitions.  Definitions and stubs
+// are provied here as a temporary workaround on AIX 6.1.
+
+#define LC_COLLATE_MASK 1
+#define LC_CTYPE_MASK   2
+#define LC_MESSAGES_MASK4
+#define LC_MONETARY_MASK8
+#define LC_NUMERIC_MASK 16
+#define LC_TIME_MASK32
+#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \
+ LC_MESSAGES_MASK | LC_MONETARY_MASK |\
+ LC_NUMERIC_MASK | LC_TIME_MASK)
+
+typedef void* locale_t;
+
+// The following are stubs.  They are not supported on AIX 6.1.
+static inline
+locale_t newlocale(int category_mask, const char *locale, locale_t base)
+{
+  _LC_locale_t *newloc, *loc;
+  if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL)
+  {
+errno = EINVAL;
+return (locale_t)0;
+  }
+  if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL)
+  {
+errno = ENOME

Re: [PATCH] D17376: dump_ast_matchers.py: fix replacement regexps

2016-02-18 Thread Yury Gribov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261219: [analyzer] dump_ast_matchers.py: fix replacement 
regexps (authored by ygribov).

Changed prior to commit:
  http://reviews.llvm.org/D17376?vs=48306&id=48316#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17376

Files:
  cfe/trunk/docs/tools/dump_ast_matchers.py

Index: cfe/trunk/docs/tools/dump_ast_matchers.py
===
--- cfe/trunk/docs/tools/dump_ast_matchers.py
+++ cfe/trunk/docs/tools/dump_ast_matchers.py
@@ -363,11 +363,11 @@
 
 reference = open('../LibASTMatchersReference.html').read()
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % node_matcher_table
+   node_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % narrowing_matcher_table
+   narrowing_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % traversal_matcher_table
+   traversal_matcher_table, reference, flags=re.S)
 
 with open('../LibASTMatchersReference.html', 'wb') as output:
   output.write(reference)


Index: cfe/trunk/docs/tools/dump_ast_matchers.py
===
--- cfe/trunk/docs/tools/dump_ast_matchers.py
+++ cfe/trunk/docs/tools/dump_ast_matchers.py
@@ -363,11 +363,11 @@
 
 reference = open('../LibASTMatchersReference.html').read()
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % node_matcher_table
+   node_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % narrowing_matcher_table
+   narrowing_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % traversal_matcher_table
+   traversal_matcher_table, reference, flags=re.S)
 
 with open('../LibASTMatchersReference.html', 'wb') as output:
   output.write(reference)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261219 - [analyzer] dump_ast_matchers.py: fix replacement regexps

2016-02-18 Thread Yury Gribov via cfe-commits
Author: ygribov
Date: Thu Feb 18 09:43:56 2016
New Revision: 261219

URL: http://llvm.org/viewvc/llvm-project?rev=261219&view=rev
Log:
[analyzer] dump_ast_matchers.py: fix replacement regexps

Patch by Alex Sidorin!

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

Modified:
cfe/trunk/docs/tools/dump_ast_matchers.py

Modified: cfe/trunk/docs/tools/dump_ast_matchers.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_ast_matchers.py?rev=261219&r1=261218&r2=261219&view=diff
==
--- cfe/trunk/docs/tools/dump_ast_matchers.py (original)
+++ cfe/trunk/docs/tools/dump_ast_matchers.py Thu Feb 18 09:43:56 2016
@@ -363,11 +363,11 @@ traversal_matcher_table = sort_table('TR
 
 reference = open('../LibASTMatchersReference.html').read()
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % node_matcher_table
+   node_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % narrowing_matcher_table
+   narrowing_matcher_table, reference, flags=re.S)
 reference = re.sub(r'',
-   '%s', reference, flags=re.S) % traversal_matcher_table
+   traversal_matcher_table, reference, flags=re.S)
 
 with open('../LibASTMatchersReference.html', 'wb') as output:
   output.write(reference)


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


Re: r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-02-18 Thread Vassil Vassilev via cfe-commits

Тhanks, could you (or smb else with commit perms) check it in?
--Vassil
On 18/02/16 03:24, Richard Smith wrote:

(And otherwise this LGTM.)

On Wed, Feb 17, 2016 at 5:24 PM, Richard Smith  wrote:

+  // TODO: Check visibility. New is hidden but has a complete type. If New
+  // has no array bound, it should not inherit one from Old, if Old is not
+  // visible.

I think this is in the wrong place: it should be attached to the "old
is complete and new is not" case. Also, our convention is to use
FIXME, not TODO.

Speaking of which, you can now delete the "FIXME: Even if this merging
succeeds, [...]" comment now, and add its example as a testcase. With
your change we should reliably diagnose it.

On Wed, Feb 17, 2016 at 2:32 PM, Vassil Vassilev  wrote:

On 16/02/16 22:20, Richard Smith wrote:

--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -419,6 +419,25 @@ static bool isPreferredLookupResult(Sema &S,
Sema::LookupNameKind Kind,
  }
}

+  // VarDecl can have incomplete array types, prefer the one with more
complete
+  // array type.
+  if (VarDecl *DVD = dyn_cast(DUnderlying)) {
+VarDecl *EVD = cast(EUnderlying);
+// Skip local VarDecls with incomplete array type.
+if ((!DVD->isLocalVarDecl() && DVD->hasExternalStorage()) ||
+(!EVD->isLocalVarDecl() && EVD->hasExternalStorage())) {

Why do you need this special case?

No reason, I decided to be conservative. All comments should be addressed in
the new version of the patch.

+
+  ASTContext &C = S.getASTContext();
+
+  if (const ArrayType *DVDTy = C.getAsArrayType(DVD->getType())) {
+const ArrayType *EVDTy = C.getAsArrayType(EVD->getType());
+// Prefer the decl with more complete type if visible.
+return !DVDTy->isIncompleteArrayType() &&
EVDTy->isIncompleteArrayType()

Checking for an array type here seems unnecessary -- it'd be simpler to
check EVD->getType()->isIncompleteType() &&
!DVD->getType()->isIncompleteType().

+ && S.isVisible(D);

This seems like a very subtle case: we're performing redeclaration lookup
for a variable declaration X, and we find two results D and E. D is hidden
but has a complete type. E is visible but has an incomplete type. If X has
no array bound, it should not inherit one from D. But if it does have an
array bound, and that bound differs from E's bound, we should diagnose the
mismatch.

Please add another test to the end of merge-incomplete-array-vars.cpp to
check this is working:
int c[2]; // expected-error {{different type: 'int [2]' vs 'int [1]'}}

That said, I think this test will fail if you reorder c1 and c2 in the
module map, but that's a pre-existing bug (see the last FIXME in
Sema::MergeVarDeclTypes).

+  }
+}
+  }


On Tue, Feb 16, 2016 at 11:12 AM, Vassil Vassilev 
wrote:

ping...

On 07/02/16 22:33, Vassil Vassilev wrote:

Improve a comment.
--Vassil
On 07/02/16 20:48, Vassil Vassilev wrote:

Would this patch be any better?
--Vassil
On 05/02/16 21:49, Richard Smith wrote:

This belongs in ASTDeclReader::attachPreviousDecl[Impl]. That's where we
propagate data that's supposed to be consistent across a redeclaration chain
from earlier declarations to later ones.

There's another wrinkle here: we should only be propagating the type from
a previous declaration that's declared in the same scope (in particular, we
should skip over declarations declared as local extern declarations within a
function). This may in some cases require walking backwards along the
redeclaration chain to find the previous declaration that was not a local
extern declaration. That'd be observable in a case like this:

modulemap:
module A { module A1 { header "a1.h" } module A2 { header "a2.h" } }
module B { header "b.h" }

a1.h:
int a[];

b.h:
void g(int(*)[], int);
void g(int(*)[1], int) = delete;
template void f(T t) {
   extern int a[];
   g(&a, t);
}

a2.h:
int a[1];

x.cc:
#include "a1.h"
#include "b.h"
void h() { f(0); } // should not produce an error; type of 'a' within 'f'
should not have been updated

That example actually reveals another problem: we really don't want the
completed type to be visible unless there is a visible declaration with the
completed type. That suggests that propagating the type across the
redeclaration chain may be the wrong approach, and we should instead handle
this by changing isPreferredLookupResult (in SemaLookup.cpp) to prefer a
VarDecl with a complete type over one with an incomplete type.

On Fri, Feb 5, 2016 at 12:27 PM, Vassil Vassilev 
wrote:

I am not sure where else to put this logic if not in isSameEntity...
Could you point me to a better place?
--Vassil

On 05/02/16 19:56, Richard Smith wrote:

On Fri, Feb 5, 2016 at 7:04 AM, Vassil Vassilev 
wrote:

Good point. Do you have in mind calling 'clang::Sema::MergeVarDeclTypes'
or we to just "duplicate" the logic in
clang::ASTDeclReader::mergeRedeclarable?


It's not safe to call into Sema while we're in a partially-deserialized
state. We know th

[PATCH] D17382: [libcxx] Split locale management out of newlib/xlocale.h. NFCI

2016-02-18 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: jroelofs, mclow.lists.
bcraig added a subscriber: cfe-commits.
Herald added a subscriber: jfb.

This is one part of many of a locale refactor. See 
http://reviews.llvm.org/D17146 for an idea of where this is going.

For the locale refactor, the locale management functions (newlocale, 
freelocale, uselocale) are needed in a separate header from the various _l 
functions. This is because some platforms implement the _l functions in terms 
of a locale switcher RAII helper, and the locale switcher RAII helper needs the 
locale management functions. This patch helps pave the way by getting all the 
functions in the right files, so that later diffs aren't completely horrible.

The "do-nothing" / "nop" locale functions are also useful on their own for 
other lightweight platforms.  Putting these nop implementations in 
support/xlocale should enable code sharing.

Unfortunately, I have no access to a newlib system to build and test with, so 
this change has been made blind. 

http://reviews.llvm.org/D17382

Files:
  include/support/newlib/xlocale.h
  include/support/xlocale/__nop_locale_mgmt.h

Index: include/support/xlocale/__nop_locale_mgmt.h
===
--- /dev/null
+++ include/support/xlocale/__nop_locale_mgmt.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===  support/xlocale/__nop_locale_mgmt.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Patch over lack of extended locale support
+typedef void *locale_t;
+static inline locale_t duplocale(locale_t) {
+  return NULL;
+}
+
+static inline void freelocale(locale_t) {
+}
+
+static inline locale_t newlocale(int, const char *, locale_t) {
+  return NULL;
+}
+
+static inline locale_t uselocale(locale_t) {
+  return NULL;
+}
+
+#define LC_COLLATE_MASK  (1 << LC_COLLATE)
+#define LC_CTYPE_MASK(1 << LC_CTYPE)
+#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
+#define LC_MONETARY_MASK (1 << LC_MONETARY)
+#define LC_NUMERIC_MASK  (1 << LC_NUMERIC)
+#define LC_TIME_MASK (1 << LC_TIME)
+#define LC_ALL_MASK (LC_COLLATE_MASK|\
+ LC_CTYPE_MASK|\
+ LC_MONETARY_MASK|\
+ LC_NUMERIC_MASK|\
+ LC_TIME_MASK|\
+ LC_MESSAGES_MASK)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
Index: include/support/newlib/xlocale.h
===
--- include/support/newlib/xlocale.h
+++ include/support/newlib/xlocale.h
@@ -16,41 +16,12 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// Patch over newlib's lack of extended locale support
-typedef void *locale_t;
-static inline locale_t duplocale(locale_t) {
-  return NULL;
-}
-
-static inline void freelocale(locale_t) {
-}
-
-static inline locale_t newlocale(int, const char *, locale_t) {
-  return NULL;
-}
-
-static inline locale_t uselocale(locale_t) {
-  return NULL;
-}
-
-#define LC_COLLATE_MASK  (1 << LC_COLLATE)
-#define LC_CTYPE_MASK(1 << LC_CTYPE)
-#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
-#define LC_MONETARY_MASK (1 << LC_MONETARY)
-#define LC_NUMERIC_MASK  (1 << LC_NUMERIC)
-#define LC_TIME_MASK (1 << LC_TIME)
-#define LC_ALL_MASK (LC_COLLATE_MASK|\
- LC_CTYPE_MASK|\
- LC_MONETARY_MASK|\
- LC_NUMERIC_MASK|\
- LC_TIME_MASK|\
- LC_MESSAGES_MASK)
-
 // Share implementation with Android's Bionic
 #include 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-18 Thread Logan Chien via cfe-commits
logan added inline comments.


Comment at: lib/Headers/unwind.h:61
@@ +60,3 @@
+#define _UNWIND_ARM_EHABI 0
+#endif
+

compnerd wrote:
> logan wrote:
> > compnerd wrote:
> > > logan wrote:
> > > > Since this is `unwind.h`, I feel that we can get a step further and use 
> > > > `__ARM_EABI_UNWINDER__` to get more compatibility to GCC's unwind.h.
> > > > 
> > > > Here's the change:
> > > > 
> > > > ```
> > > > #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
> > > > !defined(__ARM_DWARF_EH__)
> > > > #define __ARM_EABI_UNWINDER__ 1
> > > > #endif
> > > > ```
> > > I dont know if we really need to imitate GCC's macros here.  Am I 
> > > mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been set to 
> > > 1 externally if targeting such an environment?  I think that it is better 
> > > to use the reserved namespace and intrude into libunwind's namespace as 
> > > already done here.
> > > Am I mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been 
> > > set to 1 externally if targeting such an environment?
> > 
> > Although this is an implementation detail, it was defined by `unwind.h` in 
> > the implementation of GCC.
> > 
> > Remark: `__ARM_EABI_UNWINDER__` is not a pre-defined macro in GCC and Clang 
> > (can be checked with ` gcc -dM -E - < /dev/null`.)
> > 
> > BTW, some applications or libraries need this macro to be defined after 
> > including `` (such as uclibc, boost, or libc++abi 3.0.)  I 
> > remembered that someone suggested to use `__ARM_EABI_UNWINDER__` instead of 
> >  `LIBCXXABI_ARM_EHABI` when I was fixing libc++abi several years ago.  I 
> > chose `LIBCXXABI_ARM_EHABI` simply because `__ARM_EABI_UNWINDER__` wasn't 
> > provided by clang at that time.
> > 
> > I am less concerned to namespace pollution, because this is already the de 
> > facto implementation in GCC world and the macro names start with 
> > underscores are reserved for compiler or standard libraries by convention.
> > 
> > Since this is file a public header and will be used for a long time, I 
> > personally believe that it will be better to use an existing name with the 
> > same meaning instead of introducing a new name.  In addition, this will 
> > make it easier to port the application between gcc and clang.
> I just checked, libc++abi has no use of this macro, nor does boost 1.60.  
> uclibc only defines `__ARM_EABI_UNWINDER__`, but does not use it.  I also 
> checked glibc and musl, and glibc like uclibc defines it while musl has no 
> references to it.  This is injecting itself into the compiler namespace and 
> is misleading, so I think I would really rather prefer the current patch as 
> is.
> I just checked, libc++abi has no use of this macro, nor does boost 1.60. 
> uclibc only defines __ARM_EABI_UNWINDER__, but does not use it. I also 
> checked glibc and musl, and glibc like uclibc defines it while musl has no 
> references to it.

For uClibc++ and Boost I only did a simple Google search while writing the 
previous reply.  Sorry for the brevity.

Although uClibc++ itself does not use `__ARM_EABI_UNWINDER__`, some third-party 
ARM ports are using this macro.  For example, 
[toyroot](https://github.com/luckboy/toyroot), a small build system for small 
linux distribution, is maintaining a [local 
patch](https://github.com/luckboy/toyroot/blob/master/patch/uClibc%2B%2B-0.2.4-arm-eabi-unwinder.patch).
  Yet another example, [Aboriginal Linux](http://landley.net/aboriginal/) has 
[another 
patch](http://www.landley.net/hg/aboriginal/file/tip/sources/patches/uClibc%2B%2B-unwind-cxx.patch)
 that requires this macro.  Someone even sent a 
[patch](http://lists.uclibc.org/pipermail/uclibc/2012-June/046915.html) to 
uClibc++ mailing list.

For Boost, I am referring to [this 
thread](http://lists.boost.org/Archives/boost/2008/04/136332.php), although it 
seems not being committed.

For libc++abi, I am referring to the [earlier 
version](http://llvm.org/klaus/libcxxabi/blob/8b547a338373b6e149d8ceed34bbf6a979a1e10d/src/cxa_exception.hpp)
 (roughly 3.4.)  You won't find `__ARM_EABI_UNWINDER__` in libc++abi master 
branch because I removed it in 
[05d51bcf07](http://llvm.org/klaus/libcxxabi/commit/05d51bcf07d0ec1c40785b4a860fd917410b4be1/)
 when I was implementing the ARM EHABI support.  I remembered in the [review 
comments](http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140414/103125.html)
 Jonathan even suggested me to use `__ARM_EABI_UNWINDER__` instead.  I couldn't 
do  so because `__ARM_EABI_UNWINDER__` was not defined by 
`/lib/Headers/unwind.h`.

The main purpose to mention these projects is to demonstrate that 
`__ARM_EABI_UNWINDER__` is a common knownledge between unwinder or personality 
developers.  Many of us will come up with `__ARM_EABI_UNWINDER__` when we need 
to distinguish ARM EHABI code and Itanium code.

> This is injecting itself into the compiler namespace and is misleading, so I 
> think I would really rather prefer the 

Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Manman Ren via cfe-commits
On Wed, Feb 17, 2016 at 10:33 PM, Akira Hatanaka  wrote:

> ahatanak added a comment.
>
> OK, I now understand what you meant.
>
> > How about the following?
>
> >
>
> >   else if (LocalAlignment == 8) {
>
> > if (NumBytesAtAlign8 == 0) {
>
> >   // We have not seen any 8-byte aligned element yet. There is no
> padding and we are either 4-byte
>
> >   // aligned or 8-byte aligned depending on NumBytesAtAlign4.
>
> >   // Add in 4 bytes padding if we are not 8-byte aligned including
> this element.
>
> >   if ((LocalSize + NumBytesAtAlign4) % 8 != 0) {
>
> > memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
>
> > Index -= 4;
>
> >   }
>
>
> If Capacity is not a multiple of 8, (LocalSize + NumBytesAtAlign4) % 8
> doesn't tell you whether the new element will be 8-byte aligned. For
> example, if Capacity==36, NumBytesAtAlign4==4, and LocalSize==8, (LocalSize
> + NumBytesAtAlign4) equals 12 but padding is not needed as the new element
> can start at Index=24.


I don't quite get why the new element can start at Index of 24, does it
have a LocalAlignment of 8?


> Note that it's possible to have a Capacity that isn't a multiple of 8 by
> calling TypeLocBuilder::reserve.

Yeah, I probably missed the case where Capacity is not aligned.

Please update the patch.

Manman

> I think padding is needed if the new index (Index - LocalSize) is not a
> multiple of 8.
>
>
> http://reviews.llvm.org/D16843
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17382: [libcxx] Split locale management out of newlib/xlocale.h. NFCI

2016-02-18 Thread Jonathan Roelofs via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D17382



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


Re: [PATCH] D17380: [libcxx] Split locale management out of ibm/xlocale.h. NFCI

2016-02-18 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.
jroelofs accepted this revision.
jroelofs added a reviewer: jroelofs.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D17380



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


Re: [PATCH] D17375: Add parentheses around arithmetic in operand of '|' in llvm-dwp.cpp.

2016-02-18 Thread David Blaikie via cfe-commits
Thanks all! Which compiler flagged this? Wonder if/why Clang didn't flag it
for me?

On Thu, Feb 18, 2016 at 5:27 AM, Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL261207: Add parentheses around arithmetic in operand of
> '|'. (authored by d0k).
>
> Changed prior to commit:
>   http://reviews.llvm.org/D17375?vs=48301&id=48302#toc
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D17375
>
> Files:
>   llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
>
> Index: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
> ===
> --- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
> +++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
> @@ -238,7 +238,7 @@
>  while (Buckets[H]) {
>assert(S != IndexEntries[Buckets[H] - 1].Signature &&
>   "Duplicate type unit");
> -  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
> +  H = (H + (((S >> 32) & Mask) | 1)) % Buckets.size();
>  }
>  Buckets[H] = i + 1;
>}
>
>
>
> ___
> 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


r261221 - Add an AST matcher for real floating-point types. e.g., float, double, long double, but not complex.

2016-02-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Feb 18 10:36:01 2016
New Revision: 261221

URL: http://llvm.org/viewvc/llvm-project?rev=261221&view=rev
Log:
Add an AST matcher for real floating-point types. e.g., float, double, long 
double, but not complex.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=261221&r1=261220&r2=261221&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Feb 18 10:36:01 2016
@@ -2176,23 +2176,6 @@ fieldDecl(isPublic())
 
 
 
-MatcherExpr>nullPointerConstant
-Matches 
expressions that resolve to a null pointer constant, such as
-GNU's __null, C++11's nullptr, or C's NULL macro.
-
-Given:
-  void *v1 = NULL;
-  void *v2 = nullptr;
-  void *v3 = __null; GNU extension
-  char *cp = (char *)0;
-  int *ip = 0;
-  int i = 0;
-expr(nullPointerConstant())
-  matches the initializer for v1, v2, v3, cp, and ip. Does not match the
-  initializer for i.
-
-
-
 MatcherFloatingLiteral>equalsValueT  Value
 Matches literals that are 
equal to the given value.
 
@@ -2429,7 +2412,7 @@ memberExpr(isArrow())
 
 
 
-MatcherNamedDecl>hasNamestd::string  Name
+MatcherNamedDecl>hasNamestd::string Name
 Matches NamedDecl nodes 
that have the specified name.
 
 Supports specifying enclosing namespaces or classes by prefixing the name
@@ -2621,6 +2604,17 @@ matches "a(char)", "b(wchar_t)", but not
 
 
 
+MatcherQualType>isAnyPointer
+Matches QualType nodes 
that are of any pointer type.
+
+Given
+  int *i = nullptr;
+  int j;
+varDecl(hasType(isAnyPointer()))
+  matches "int *i", but not "int j".
+
+
+
 MatcherQualType>isConstQualified
 Matches QualType 
nodes that are const-qualified, i.e., that
 include "top-level" const.
@@ -2894,6 +2888,17 @@ and reference to that variable declarati
 
 
 
+MatcherType>realFloatingPointType
+Matches any 
real floating-point type (float, double, long double).
+
+Given
+  int i;
+  float f;
+realFloatingPointType()
+  matches "float f" but not "int i"
+
+
+
 MatcherType>voidType
 Matches type void.
 
@@ -3080,6 +3085,23 @@ functionDecl(isInstantiated())
 
 
 
+MatcherExpr>>nullPointerConstant
+Matches 
expressions that resolve to a null pointer constant, such as
+GNU's __null, C++11's nullptr, or C's NULL macro.
+
+Given:
+  void *v1 = NULL;
+  void *v2 = nullptr;
+  void *v3 = __null; GNU extension
+  char *cp = (char *)0;
+  int *ip = 0;
+  int i = 0;
+expr(nullPointerConstant())
+  matches the initializer for v1, v2, v3, cp, and ip. Does not match the
+  initializer for i.
+
+
+
 MatcherStmt>>isInTemplateInstantiation
 Matches 
statements inside of a template instantiation.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=261221&r1=261220&r2=261221&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Feb 18 10:36:01 2016
@@ -3961,6 +3961,19 @@ AST_TYPE_MATCHER(ArrayType, arrayType);
 ///   matches "_Complex float f"
 AST_TYPE_MATCHER(ComplexType, complexType);
 
+/// \brief Matches any real floating-point type (float, double, long double).
+///
+/// Given
+/// \code
+///   int i;
+///   float f;
+/// \endcode
+/// realFloatingPointType()
+///   matches "float f" but not "int i"
+AST_MATCHER(Type, realFloatingPointType) {
+  return Node.isRealFloatingType();
+}
+
 /// \brief Matches arrays and C99 complex types that have a specific element
 /// type.
 ///

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=261221&r1=261220&r2=261221&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Thu Feb 18 10:3

Re: [PATCH] D17375: Add parentheses around arithmetic in operand of '|' in llvm-dwp.cpp.

2016-02-18 Thread Benjamin Kramer via cfe-commits
On Thu, Feb 18, 2016 at 5:39 PM, David Blaikie  wrote:
> Thanks all! Which compiler flagged this? Wonder if/why Clang didn't flag it
> for me?

It was coming from GCC 4.9. Haven't checked if Clang also has this somewhere.

> On Thu, Feb 18, 2016 at 5:27 AM, Phabricator via cfe-commits
>  wrote:
>>
>> This revision was automatically updated to reflect the committed changes.
>> Closed by commit rL261207: Add parentheses around arithmetic in operand of
>> '|'. (authored by d0k).
>>
>> Changed prior to commit:
>>   http://reviews.llvm.org/D17375?vs=48301&id=48302#toc
>>
>> Repository:
>>   rL LLVM
>>
>> http://reviews.llvm.org/D17375
>>
>> Files:
>>   llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
>>
>> Index: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
>> ===
>> --- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
>> +++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
>> @@ -238,7 +238,7 @@
>>  while (Buckets[H]) {
>>assert(S != IndexEntries[Buckets[H] - 1].Signature &&
>>   "Duplicate type unit");
>> -  H = (H + ((S >> 32) & Mask) | 1) % Buckets.size();
>> +  H = (H + (((S >> 32) & Mask) | 1)) % Buckets.size();
>>  }
>>  Buckets[H] = i + 1;
>>}
>>
>>
>>
>> ___
>> 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


r261222 - Avoid double deletion in Clang driver.

2016-02-18 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Thu Feb 18 10:42:09 2016
New Revision: 261222

URL: http://llvm.org/viewvc/llvm-project?rev=261222&view=rev
Log:
Avoid double deletion in Clang driver.

Llvm module object is shared between CodeGenerator and BackendConsumer,
in both classes it is stored as std::unique_ptr, which is not a good
design solution and can cause double deletion error. Usually it does
not occur because in BackendConsumer::HandleTranslationUnit the
ownership of CodeGenerator over the module is taken away. If however
this method is not called, the module is deleted twice and compiler crashes.

As the module owned by BackendConsumer is always the same as CodeGenerator
has, pointer to llvm module can be removed from BackendGenerator.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/unittests/Frontend/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=261222&r1=261221&r2=261222&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Feb 18 10:42:09 2016
@@ -53,7 +53,6 @@ namespace clang {
 
 std::unique_ptr Gen;
 
-std::unique_ptr TheModule;
 SmallVector>, 4>
 LinkModules;
 
@@ -81,7 +80,10 @@ namespace clang {
 this->LinkModules.push_back(
 std::make_pair(I.first, std::unique_ptr(I.second)));
 }
-std::unique_ptr takeModule() { return std::move(TheModule); }
+llvm::Module *getModule() const { return Gen->GetModule(); }
+std::unique_ptr takeModule() {
+  return std::unique_ptr(Gen->ReleaseModule());
+}
 void releaseLinkModules() {
   for (auto &I : LinkModules)
 I.second.release();
@@ -101,8 +103,6 @@ namespace clang {
 
   Gen->Initialize(Ctx);
 
-  TheModule.reset(Gen->GetModule());
-
   if (llvm::TimePassesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
@@ -149,25 +149,12 @@ namespace clang {
   }
 
   // Silently ignore if we weren't initialized for some reason.
-  if (!TheModule)
-return;
-
-  // Make sure IR generation is happy with the module. This is released by
-  // the module provider.
-  llvm::Module *M = Gen->ReleaseModule();
-  if (!M) {
-// The module has been released by IR gen on failures, do not double
-// free.
-TheModule.release();
+  if (!getModule())
 return;
-  }
-
-  assert(TheModule.get() == M &&
- "Unexpected module change during IR generation");
 
   // Install an inline asm handler so that diagnostics get printed through
   // our diagnostics hooks.
-  LLVMContext &Ctx = TheModule->getContext();
+  LLVMContext &Ctx = getModule()->getContext();
   LLVMContext::InlineAsmDiagHandlerTy OldHandler =
 Ctx.getInlineAsmDiagnosticHandler();
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
@@ -182,13 +169,13 @@ namespace clang {
   for (auto &I : LinkModules) {
 unsigned LinkFlags = I.first;
 CurLinkModule = I.second.get();
-if (Linker::linkModules(*M, std::move(I.second), LinkFlags))
+if (Linker::linkModules(*getModule(), std::move(I.second), LinkFlags))
   return;
   }
 
   EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
 C.getTargetInfo().getDataLayoutString(),
-TheModule.get(), Action, AsmOutStream);
+getModule(), Action, AsmOutStream);
 
   Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
 

Modified: cfe/trunk/unittests/Frontend/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CMakeLists.txt?rev=261222&r1=261221&r2=261222&view=diff
==
--- cfe/trunk/unittests/Frontend/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Frontend/CMakeLists.txt Thu Feb 18 10:42:09 2016
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(FrontendTests
   FrontendActionTest.cpp
+  CodeGenActionTest.cpp
   )
 target_link_libraries(FrontendTests
   clangAST
@@ -11,4 +12,5 @@ target_link_libraries(FrontendTests
   clangFrontend
   clangLex
   clangSema
+  clangCodeGen
   )


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


Re: [PATCH] D15450: Avoid double deletion in Clang driver.

2016-02-18 Thread Serge Pavlov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261222: Avoid double deletion in Clang driver. (authored by 
sepavloff).

Changed prior to commit:
  http://reviews.llvm.org/D15450?vs=46575&id=48332#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15450

Files:
  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
  cfe/trunk/unittests/Frontend/CMakeLists.txt

Index: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp
@@ -53,7 +53,6 @@
 
 std::unique_ptr Gen;
 
-std::unique_ptr TheModule;
 SmallVector>, 4>
 LinkModules;
 
@@ -81,7 +80,10 @@
 this->LinkModules.push_back(
 std::make_pair(I.first, std::unique_ptr(I.second)));
 }
-std::unique_ptr takeModule() { return std::move(TheModule); }
+llvm::Module *getModule() const { return Gen->GetModule(); }
+std::unique_ptr takeModule() {
+  return std::unique_ptr(Gen->ReleaseModule());
+}
 void releaseLinkModules() {
   for (auto &I : LinkModules)
 I.second.release();
@@ -101,8 +103,6 @@
 
   Gen->Initialize(Ctx);
 
-  TheModule.reset(Gen->GetModule());
-
   if (llvm::TimePassesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
@@ -149,25 +149,12 @@
   }
 
   // Silently ignore if we weren't initialized for some reason.
-  if (!TheModule)
-return;
-
-  // Make sure IR generation is happy with the module. This is released by
-  // the module provider.
-  llvm::Module *M = Gen->ReleaseModule();
-  if (!M) {
-// The module has been released by IR gen on failures, do not double
-// free.
-TheModule.release();
+  if (!getModule())
 return;
-  }
-
-  assert(TheModule.get() == M &&
- "Unexpected module change during IR generation");
 
   // Install an inline asm handler so that diagnostics get printed through
   // our diagnostics hooks.
-  LLVMContext &Ctx = TheModule->getContext();
+  LLVMContext &Ctx = getModule()->getContext();
   LLVMContext::InlineAsmDiagHandlerTy OldHandler =
 Ctx.getInlineAsmDiagnosticHandler();
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
@@ -182,13 +169,13 @@
   for (auto &I : LinkModules) {
 unsigned LinkFlags = I.first;
 CurLinkModule = I.second.get();
-if (Linker::linkModules(*M, std::move(I.second), LinkFlags))
+if (Linker::linkModules(*getModule(), std::move(I.second), LinkFlags))
   return;
   }
 
   EmitBackendOutput(Diags, CodeGenOpts, TargetOpts, LangOpts,
 C.getTargetInfo().getDataLayoutString(),
-TheModule.get(), Action, AsmOutStream);
+getModule(), Action, AsmOutStream);
 
   Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
 
Index: cfe/trunk/unittests/Frontend/CMakeLists.txt
===
--- cfe/trunk/unittests/Frontend/CMakeLists.txt
+++ cfe/trunk/unittests/Frontend/CMakeLists.txt
@@ -4,11 +4,13 @@
 
 add_clang_unittest(FrontendTests
   FrontendActionTest.cpp
+  CodeGenActionTest.cpp
   )
 target_link_libraries(FrontendTests
   clangAST
   clangBasic
   clangFrontend
   clangLex
   clangSema
+  clangCodeGen
   )


Index: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp
@@ -53,7 +53,6 @@
 
 std::unique_ptr Gen;
 
-std::unique_ptr TheModule;
 SmallVector>, 4>
 LinkModules;
 
@@ -81,7 +80,10 @@
 this->LinkModules.push_back(
 std::make_pair(I.first, std::unique_ptr(I.second)));
 }
-std::unique_ptr takeModule() { return std::move(TheModule); }
+llvm::Module *getModule() const { return Gen->GetModule(); }
+std::unique_ptr takeModule() {
+  return std::unique_ptr(Gen->ReleaseModule());
+}
 void releaseLinkModules() {
   for (auto &I : LinkModules)
 I.second.release();
@@ -101,8 +103,6 @@
 
   Gen->Initialize(Ctx);
 
-  TheModule.reset(Gen->GetModule());
-
   if (llvm::TimePassesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
@@ -149,25 +149,12 @@
   }
 
   // Silently ignore if we weren't initialized for some reason.
-  if (!TheModule)
-return;
-
-  // Make sure IR generation is happy with the module. This is released by
-  // the module provider.
-  llvm::Module *M = Gen->ReleaseModule();
-  if (!M) {
-// The module has been released by IR gen on failures, do not double
-// free.
-TheModule.release();
+  if (!getModule())
 return;
-  }
-
-  assert(TheModule.get() == M &&
- "Unexpected module change during 

Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Akira Hatanaka via cfe-commits
On Thu, Feb 18, 2016 at 8:10 AM, Manman Ren  wrote:

>
>
> On Wed, Feb 17, 2016 at 10:33 PM, Akira Hatanaka 
> wrote:
>
>> ahatanak added a comment.
>>
>> OK, I now understand what you meant.
>>
>> > How about the following?
>>
>> >
>>
>> >   else if (LocalAlignment == 8) {
>>
>> > if (NumBytesAtAlign8 == 0) {
>>
>> >   // We have not seen any 8-byte aligned element yet. There is no
>> padding and we are either 4-byte
>>
>> >   // aligned or 8-byte aligned depending on NumBytesAtAlign4.
>>
>> >   // Add in 4 bytes padding if we are not 8-byte aligned including
>> this element.
>>
>> >   if ((LocalSize + NumBytesAtAlign4) % 8 != 0) {
>>
>> > memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
>>
>> > Index -= 4;
>>
>> >   }
>>
>>
>> If Capacity is not a multiple of 8, (LocalSize + NumBytesAtAlign4) % 8
>> doesn't tell you whether the new element will be 8-byte aligned. For
>> example, if Capacity==36, NumBytesAtAlign4==4, and LocalSize==8, (LocalSize
>> + NumBytesAtAlign4) equals 12 but padding is not needed as the new element
>> can start at Index=24.
>
>
> I don't quite get why the new element can start at Index of 24, does it
> have a LocalAlignment of 8?
>
>

This part is enclosed in "else if (LocalAlignment == 8)", so it's
LocalAlignment should be 8 and it can start at Index=24 (which is 8-byte
aligned), no? By new element, I meant the element that is currently being
pushed.


> Note that it's possible to have a Capacity that isn't a multiple of 8 by
>> calling TypeLocBuilder::reserve.
>
> Yeah, I probably missed the case where Capacity is not aligned.
>
> Please update the patch.
>
> Manman
>
>> I think padding is needed if the new index (Index - LocalSize) is not a
>> multiple of 8.
>>
>>
>> http://reviews.llvm.org/D16843
>>
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261223 - File missed from r261222

2016-02-18 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Thu Feb 18 10:43:24 2016
New Revision: 261223

URL: http://llvm.org/viewvc/llvm-project?rev=261223&view=rev
Log:
File missed from r261222

Added:
cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp

Added: cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp?rev=261223&view=auto
==
--- cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp (added)
+++ cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp Thu Feb 18 10:43:24 2016
@@ -0,0 +1,61 @@
+//===- unittests/Frontend/CodeGenActionTest.cpp --- FrontendAction tests 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Unit tests for CodeGenAction.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/CodeGen/BackendUtil.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::frontend;
+
+namespace {
+
+
+class NullCodeGenAction : public CodeGenAction {
+public:
+  NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
+: CodeGenAction(Backend_EmitLL, _VMContext) {}
+
+  // The action does not call methods of ATContext.
+  void ExecuteAction() override {
+CompilerInstance &CI = getCompilerInstance();
+if (!CI.hasPreprocessor())
+  return;
+if (!CI.hasSema())
+  CI.createSema(getTranslationUnitKind(), nullptr);
+  }
+};
+
+
+TEST(CodeGenTest, TestNullCodeGen) {
+  CompilerInvocation *Invocation = new CompilerInvocation;
+  Invocation->getPreprocessorOpts().addRemappedFile(
+  "test.cc",
+  MemoryBuffer::getMemBuffer("").release());
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile("test.cc", IK_CXX));
+  Invocation->getFrontendOpts().ProgramAction = EmitLLVM;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(Invocation);
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  std::unique_ptr Act(new NullCodeGenAction);
+  bool Success = Compiler.ExecuteAction(*Act);
+  EXPECT_TRUE(Success);
+}
+
+}


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


Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-02-18 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3799-3806
@@ -3780,4 +3798,10 @@
   OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// \brief Emit the num_teams clause of an enclosed teams directive at the
+/// target region scope. If there is no teams directive associated with the
+/// target directive, or if there is no num_teams clause associated with the
+/// enclosed teams directive, return nullptr.
+static llvm::Value *
+emitNumTeamsClauseForTargetDirective(CodeGenFunction &CGF,

ABataev wrote:
> I don't understand why global var is not captured in target region. If it is 
> not implemented yet, it must be implemented. If it is not captured, it must 
> be captured in Sema. We should not introduce some function/other objects to 
> find a workaround for 'not implemented' features.
Sorry, I was not clear in my comment. It is not that globals are not captured 
in target regions - they are, we already have Sema doing that. 

My point is that exactly because we capture globals in target regions the magic 
that `OMPCapturedExprDecl` introduces does not work for that specific case. So, 
if we have something like:

```
int Gbl;

foo() {
  #pragma omp target
  #pragma omp teams num_teams(Gbl)
  {}
}
```
when the DeclRefExpr for Gbl used in num_teams is emitted in the scope that 
encloses '#pragma omp target', it will crash because Gbl is not a local and is 
marked as refer to enclosing capture. 

If I got it right, a solution based on `OMPCapturedExprDecl` basically makes 
local declarations whose initializers are the expression we are interested in. 
In the cases that  `OMPCapturedExprDecl` is currently employed we don't have 
globals being captured and that is why it works fine.

It is likely I am missing something here. Let me know if you need me to provide 
more details.

Thanks!


http://reviews.llvm.org/D17019



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


[PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-18 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

http://reviews.llvm.org/D17385

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -250,7 +250,7 @@
   verifyFormat("f({'a': [{}]});");
 }
 
-TEST_F(FormatTestJS, SingleQuoteStrings) {
+TEST_F(FormatTestJS, SingleQuotedStrings) {
   verifyFormat("this.function('', true);");
 }
 
@@ -1085,5 +1085,16 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, RequoteDoubleQuotedStrings) {
+  EXPECT_EQ("var x = 'foo';", format("var x = \"foo\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo'o'\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo\\'o'\";"));
+  EXPECT_EQ("var x =\n"
+"'foo\\'';",
+// Code below is 15 chars wide, doesn't fit into the line with the
+// escaped added.
+format("var x = \"foo'\";", getGoogleJSStyleWithColumns(15)));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/YAMLTraits.h"
 #include 
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -1328,6 +1329,35 @@
   Column = FormatTok->LastLineColumnWidth;
 }
 
+if (Style.Language == FormatStyle::LK_JavaScript &&
+FormatTok->isStringLiteral() && FormatTok->TokenText.startswith("\"")) {
+  // Double quoted JavaScript strings get requoted as single quoted below.
+  // For formatting, count the number of non-escaped single quotes in them
+  // and adjust ColumnWidth to take the later added escapes into account.
+
+  StringRef Input = FormatTok->TokenText;
+  bool Escaped = false;
+  size_t ColumnWidth = FormatTok->TokenText.size();
+  for (size_t i = 0; i != Input.size(); ++i) {
+switch (Input[i]) {
+case '\\':
+  Escaped = !Escaped;
+  break;
+case '\'':
+  if (!Escaped) {
+// Will later need to insert a \ to escape the double quote.
+ColumnWidth++;
+  }
+  Escaped = false;
+  break;
+default:
+  Escaped = false;
+  break;
+}
+  }
+  FormatTok->ColumnWidth = ColumnWidth;
+}
+
 if (Style.Language == FormatStyle::LK_Cpp) {
   if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() &&
 Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() ==
@@ -1495,7 +1525,12 @@
 UnwrappedLineFormatter(&Indenter, &Whitespaces, Style, Tokens.getKeywords(),
IncompleteFormat)
 .format(AnnotatedLines);
-return Whitespaces.generateReplacements();
+tooling::Replacements Replaces = Whitespaces.generateReplacements();
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  FormatToken *Tok = (*AnnotatedLines.begin())->First;
+  requoteJSStringLiterals(Replaces, Tok);
+}
+return Replaces;
   }
 
 private:
@@ -1538,6 +1573,42 @@
 return SomeLineAffected;
   }
 
+  // Finds all double-quoted string literals, and replaces them with single
+  // quoted string literals, escaping the contents in the process.
+  // The width of the extra \ escapes is taken into account in getNextToken.
+  void requoteJSStringLiterals(tooling::Replacements &Replaces,
+   FormatToken *Current) {
+for (; Current != nullptr; Current = Current->Next) {
+  if (!Current->isStringLiteral() || !Current->TokenText.startswith("\""))
+continue;
+  StringRef Input = Current->TokenText;
+  std::stringstream Res;
+  Res << '\'';
+  bool escaped = false;
+  for (size_t i = 1; i < Input.size() - 1; i++) {
+switch (Input[i]) {
+case '\\':
+  escaped = !escaped;
+  break;
+case '\'':
+  if (!escaped) {
+Res << '\\';
+  }
+  escaped = false;
+  break;
+default:
+  escaped = false;
+  break;
+}
+Res << Input[i];
+  }
+  Res << '\'';
+  SourceRange Range(Current->Tok.getLocation(), Current->Tok.getEndLoc());
+  Replaces.insert(tooling::Replacement(
+  SourceMgr, CharSourceRange::getCharRange(Range), Res.str()));
+}
+  }
+
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.
   bool nonPPLineAffected(AnnotatedLine *Line,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.l

Re: r257763 - clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.

2016-02-18 Thread Hans Wennborg via cfe-commits
On Thu, Jan 14, 2016 at 5:36 AM, Daniel Jasper via cfe-commits
 wrote:
> Author: djasper
> Date: Thu Jan 14 07:36:46 2016
> New Revision: 257763
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257763&view=rev
> Log:
> clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.
>
> Before:
>   []
>   .();
>
> After:
>   [].();
>
> Modified:
> cfe/trunk/lib/Format/ContinuationIndenter.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp

Daniel requested that this gets merged to 3.8, and so I've merged it in r261225.

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


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Akira Hatanaka via cfe-commits
On Thu, Feb 18, 2016 at 8:47 AM, Akira Hatanaka  wrote:

> On Thu, Feb 18, 2016 at 8:10 AM, Manman Ren  wrote:
>
>>
>>
>> On Wed, Feb 17, 2016 at 10:33 PM, Akira Hatanaka 
>> wrote:
>>
>>> ahatanak added a comment.
>>>
>>> OK, I now understand what you meant.
>>>
>>> > How about the following?
>>>
>>> >
>>>
>>> >   else if (LocalAlignment == 8) {
>>>
>>> > if (NumBytesAtAlign8 == 0) {
>>>
>>> >   // We have not seen any 8-byte aligned element yet. There is no
>>> padding and we are either 4-byte
>>>
>>> >   // aligned or 8-byte aligned depending on NumBytesAtAlign4.
>>>
>>> >   // Add in 4 bytes padding if we are not 8-byte aligned including
>>> this element.
>>>
>>> >   if ((LocalSize + NumBytesAtAlign4) % 8 != 0) {
>>>
>>> > memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
>>>
>>> > Index -= 4;
>>>
>>> >   }
>>>
>>>
>>> If Capacity is not a multiple of 8, (LocalSize + NumBytesAtAlign4) % 8
>>> doesn't tell you whether the new element will be 8-byte aligned. For
>>> example, if Capacity==36, NumBytesAtAlign4==4, and LocalSize==8, (LocalSize
>>> + NumBytesAtAlign4) equals 12 but padding is not needed as the new element
>>> can start at Index=24.
>>
>>
>> I don't quite get why the new element can start at Index of 24, does it
>> have a LocalAlignment of 8?
>>
>>
>
> This part is enclosed in "else if (LocalAlignment == 8)", so it's
> LocalAlignment should be 8 and it can start at Index=24 (which is 8-byte
> aligned), no? By new element, I meant the element that is currently being
> pushed.
>
>

Also, in case it wasn't clear, when I say the new element (of size 8)
starts at Index=24, I mean the first byte of the element is byte 24 and the
last byte is byte 31.


> Note that it's possible to have a Capacity that isn't a multiple of 8 by
>>> calling TypeLocBuilder::reserve.
>>
>> Yeah, I probably missed the case where Capacity is not aligned.
>>
>> Please update the patch.
>>
>> Manman
>>
>>> I think padding is needed if the new index (Index - LocalSize) is not a
>>> multiple of 8.
>>>
>>>
>>> http://reviews.llvm.org/D16843
>>>
>>>
>>>
>>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17385: clang-format: [JS] single quote double quoted strings.

2016-02-18 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 48338.
mprobst added a comment.

Fixed typo.


http://reviews.llvm.org/D17385

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -250,7 +250,7 @@
   verifyFormat("f({'a': [{}]});");
 }
 
-TEST_F(FormatTestJS, SingleQuoteStrings) {
+TEST_F(FormatTestJS, SingleQuotedStrings) {
   verifyFormat("this.function('', true);");
 }
 
@@ -1085,5 +1085,16 @@
getGoogleJSStyleWithColumns(20)));
 }
 
+TEST_F(FormatTestJS, RequoteDoubleQuotedStrings) {
+  EXPECT_EQ("var x = 'foo';", format("var x = \"foo\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo'o'\";"));
+  EXPECT_EQ("var x = 'fo\\'o\\'';", format("var x = \"fo\\'o'\";"));
+  EXPECT_EQ("var x =\n"
+"'foo\\'';",
+// Code below is 15 chars wide, doesn't fit into the line with the
+// \ escape added.
+format("var x = \"foo'\";", getGoogleJSStyleWithColumns(15)));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/YAMLTraits.h"
 #include 
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -1328,6 +1329,35 @@
   Column = FormatTok->LastLineColumnWidth;
 }
 
+if (Style.Language == FormatStyle::LK_JavaScript &&
+FormatTok->isStringLiteral() && FormatTok->TokenText.startswith("\"")) {
+  // Double quoted JavaScript strings get requoted as single quoted below.
+  // For formatting, count the number of non-escaped single quotes in them
+  // and adjust ColumnWidth to take the later added escapes into account.
+
+  StringRef Input = FormatTok->TokenText;
+  bool Escaped = false;
+  size_t ColumnWidth = FormatTok->TokenText.size();
+  for (size_t i = 0; i != Input.size(); ++i) {
+switch (Input[i]) {
+case '\\':
+  Escaped = !Escaped;
+  break;
+case '\'':
+  if (!Escaped) {
+// Will later need to insert a \ to escape the double quote.
+ColumnWidth++;
+  }
+  Escaped = false;
+  break;
+default:
+  Escaped = false;
+  break;
+}
+  }
+  FormatTok->ColumnWidth = ColumnWidth;
+}
+
 if (Style.Language == FormatStyle::LK_Cpp) {
   if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() &&
 Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() ==
@@ -1495,7 +1525,12 @@
 UnwrappedLineFormatter(&Indenter, &Whitespaces, Style, Tokens.getKeywords(),
IncompleteFormat)
 .format(AnnotatedLines);
-return Whitespaces.generateReplacements();
+tooling::Replacements Replaces = Whitespaces.generateReplacements();
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  FormatToken *Tok = (*AnnotatedLines.begin())->First;
+  requoteJSStringLiterals(Replaces, Tok);
+}
+return Replaces;
   }
 
 private:
@@ -1538,6 +1573,42 @@
 return SomeLineAffected;
   }
 
+  // Finds all double-quoted string literals, and replaces them with single
+  // quoted string literals, escaping the contents in the process.
+  // The width of the extra \ escapes is taken into account in getNextToken.
+  void requoteJSStringLiterals(tooling::Replacements &Replaces,
+   FormatToken *Current) {
+for (; Current != nullptr; Current = Current->Next) {
+  if (!Current->isStringLiteral() || !Current->TokenText.startswith("\""))
+continue;
+  StringRef Input = Current->TokenText;
+  std::stringstream Res;
+  Res << '\'';
+  bool escaped = false;
+  for (size_t i = 1; i < Input.size() - 1; i++) {
+switch (Input[i]) {
+case '\\':
+  escaped = !escaped;
+  break;
+case '\'':
+  if (!escaped) {
+Res << '\\';
+  }
+  escaped = false;
+  break;
+default:
+  escaped = false;
+  break;
+}
+Res << Input[i];
+  }
+  Res << '\'';
+  SourceRange Range(Current->Tok.getLocation(), Current->Tok.getEndLoc());
+  Replaces.insert(tooling::Replacement(
+  SourceMgr, CharSourceRange::getCharRange(Range), Res.str()));
+}
+  }
+
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.
   bool nonPPLineAffected(AnnotatedLine *Line,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17387: Add check for CERT FLP30-C

2016-02-18 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, sbenza.
aaron.ballman added a subscriber: cfe-commits.

This patch adds a check for the CERT secure coding rule: FLP30-C. Do not use 
floating-point variables as loop counters. It flags any for loop induction 
expression that has floating-point type.

https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters

http://reviews.llvm.org/D17387

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/FloatLoopCounter.cpp
  clang-tidy/cert/FloatLoopCounter.h
  docs/clang-tidy/checks/cert-flp30-c.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-flp30-c.c

Index: test/clang-tidy/cert-flp30-c.c
===
--- test/clang-tidy/cert-flp30-c.c
+++ test/clang-tidy/cert-flp30-c.c
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s cert-flp30-c %t
+
+float g(void);
+
+void func(void) {
+  // CHECK-MESSAGES: :[[@LINE+1]]:37: warning: loop induction expression should not have floating-point type [cert-flp30-c]
+  for (float x = 0.1f; x <= 1.0f; x += 0.1f) {
+  }
+
+  float f = 1.0f;
+  // CHECK-MESSAGES: :[[@LINE+1]]:17: warning: loop induction expression
+  for (; f > 0; --f) {
+  }
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:10: warning: loop induction expression
+  for (;;g()) {
+  }
+
+  for (int i = 0; i < 10; i += 1.0f) {
+  }
+
+  for (int i = 0; i < 10; ++i) {
+  }
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -13,6 +13,7 @@
cert-err60-cpp
cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) 
cert-fio38-c (redirects to misc-non-copyable-objects) 
+   cert-flp30-c
cert-oop11-cpp (redirects to misc-move-constructor-init) 
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
Index: docs/clang-tidy/checks/cert-flp30-c.rst
===
--- docs/clang-tidy/checks/cert-flp30-c.rst
+++ docs/clang-tidy/checks/cert-flp30-c.rst
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - cert-flp30-c
+
+cert-flp30-c
+
+
+This check flags ``for`` loops where the induction expression has a floating-
+point type.
+
+This check corresponds to the CERT C Coding Standard rule
+`FLP30-C. Do not use floating-point variables as loop counters
+`_.
Index: clang-tidy/cert/FloatLoopCounter.h
===
--- clang-tidy/cert/FloatLoopCounter.h
+++ clang-tidy/cert/FloatLoopCounter.h
@@ -0,0 +1,37 @@
+//===--- FloatLoopCounter.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_CERT_FLOAT_LOOP_COUNTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_FLOAT_LOOP_COUNTER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+/// This check diagnoses when the loop induction expression of a for loop has
+/// floating-point type. The check corresponds to:
+/// https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-flp30-c.html
+class FloatLoopCounter : public ClangTidyCheck {
+public:
+  FloatLoopCounter(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_FLOAT_LOOP_COUNTER_H
Index: clang-tidy/cert/FloatLoopCounter.cpp
===
--- clang-tidy/cert/FloatLoopCounter.cpp
+++ clang-tidy/cert/FloatLoopCounter.cpp
@@ -0,0 +1,35 @@
+//===--- FloatLoopCounter.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 "FloatLoopCounter.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers

[PATCH] D17389: Embed bitcode in object file (clang cc1 part)

2016-02-18 Thread Steven Wu via cfe-commits
steven_wu created this revision.
steven_wu added a subscriber: cfe-commits.
Herald added subscribers: dschuff, jfb.

Teach clang to embed bitcode inside bitcode. When -fembed-bitcode cc1
option is used, clang will embed both the input bitcode and cc1
commandline into the bitcode in special sections before compiling to
the object file.  Using -fembed-bitcode-marker will only introduce a
marker in both sections.

Don't emit uselist order for -fembed-bitcode

Embedded bitcode are embedded without serialization in their normal
flow. No uselist order need to be recorded.

Apply whitelist to options used in embedded bitcode

Add a whitelist for the options that are allowed to be used with
-fembed-bitcode. That is minimize the number of the cc1 command
that needs to be embedded in the object file.

http://reviews.llvm.org/D17389

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/CodeGen/BackendUtil.h
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/embed-bitcode.c
  test/Frontend/embed-bitcode.ll

Index: test/Frontend/embed-bitcode.ll
===
--- /dev/null
+++ test/Frontend/embed-bitcode.ll
@@ -0,0 +1,48 @@
+; check .ll input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode -x ir %s -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode-marker -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+; RUN: %clang_cc1 -triple aarch64-unknown-linux-gnueabi -emit-llvm \
+; RUN:-fembed-bitcode -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ELF
+
+; check .bc input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-x ir %s -o %t.bc
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode -x ir %t.bc -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode-marker -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+
+; run through -fembed-bitcode twice and make sure it doesn't crash
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-fembed-bitcode -x ir %s -o - \
+; RUN: | %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode -x ir - -o /dev/null
+
+; check the magic number of bitcode at the beginning of the string
+; CHECK: @llvm.embedded.module
+; CHECK: c"\DE\C0\17\0B
+; CHECK: section "__LLVM,__bitcode"
+; CHECK: @llvm.cmdline
+; CHECK: section "__LLVM,__cmdline"
+
+; CHECK-ELF: @llvm.embedded.module
+; CHECK-ELF: section ".llvmbc"
+; CHECK-ELF: @llvm.cmdline
+; CHECK-ELF: section ".llvmcmd"
+
+; CHECK-MARKER: @llvm.embedded.module
+; CHECK-MARKER: constant [0 x i8] zeroinitializer
+; CHECK-MARKER: section "__LLVM,__bitcode"
+; CHECK-MARKER: @llvm.cmdline
+; CHECK-MARKER: section "__LLVM,__cmdline"
+
+define i32 @f0() {
+  ret i32 0
+}
Index: test/Driver/embed-bitcode.c
===
--- test/Driver/embed-bitcode.c
+++ test/Driver/embed-bitcode.c
@@ -5,6 +5,7 @@
 // RUN: %clang %s -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-CC
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-llvm-bc
+// CHECK-CC-NOT: -emit-llvm-uselists
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-obj
 // CHECK-CC: -fembed-bitcode
@@ -24,3 +25,62 @@
 // CHECK-MARKER: -fembed-bitcode-marker
 // CHECK-MARKER-NOT: -cc1
 
+// Check clang complains about ios version min if it is used to generate link command.
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=6.0 %s -fembed-bitcode -### 2>&1 | \
+// RUN:   FileCheck %s -check-prefix=CHECK-PLATFORM-SUPPORTED
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=5.0 %s -fembed-bitcode -### 2>&1 | \
+// RUN:   FileCheck %s -check-prefix=CHECK-PLATFORM-UNSUPPORTED
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=5.0 -c %s -fembed-bitcode -### 2>&1 | \
+// RUN:   FileCheck %s -check-prefix=CHECK-PLATFORM-SUPPORTED
+// CHECK-PLATFORM-SUPPORTED-NOT: -fembed-bitcode is not supported on versions of iOS prior to 6.0
+// CHECK-PLATFORM-UNSUPPORTED: -fembed-bitcode is not supported on versions of iOS prior to 6.0
+
+// RUN: %clang -c %s -fembed-bitcode -mkernel -fapple-kext -ffunction-sections \
+// RUN:   -fno-function-sections -fdata-sections -fno-data-sections \
+// RUN:   -funique-section-names -fno-unique-section-names -mrestrict-it \
+// RUN:   -mno-restrict-it -mstackrealgin -mno-stackrealign -mstack-alignment=8 \
+// RUN:   -mcmodel=small -mlong-calls -mno-long-calls -ggnu-pubnames \
+// RUN:   -gdwarf-arange -fdebug-types-section -fno-debug-types-section \
+// RUN:   -fdwarf-directory-asm -fno-dwarf-dire

[PATCH] D17390: Introduce -fembed-bitcode driver option

2016-02-18 Thread Steven Wu via cfe-commits
steven_wu created this revision.
steven_wu added a subscriber: cfe-commits.

This is the clang driver part of the change to embedded bitcode. This
includes:
1. -fembed-bitcode option which breaks down the compilation into two
stages. The first stage emits optimized bitcode and the second stage
compiles bitcode into object file.
2. -fembed-bitcode-marker option which doesn't really break down to
two stages to speedup the compilation flow.
3. pass the correct linker flag to darwin linker if tool chains supports
embedded bitcode.

http://reviews.llvm.org/D17390

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/embed-bitcode.c

Index: test/Driver/embed-bitcode.c
===
--- /dev/null
+++ test/Driver/embed-bitcode.c
@@ -0,0 +1,26 @@
+// RUN: %clang -ccc-print-bindings -c %s -fembed-bitcode 2>&1 | FileCheck %s
+// CHECK: clang
+// CHECK: clang
+
+// RUN: %clang %s -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-CC
+// CHECK-CC: -cc1
+// CHECK-CC: -emit-llvm-bc
+// CHECK-CC: -cc1
+// CHECK-CC: -emit-obj
+// CHECK-CC: -fembed-bitcode
+// CHECK-CC: ld
+// CHECK-CC: -bitcode_bundle
+
+// RUN: %clang -c %s -flto -fembed-bitcode 2>&1 -### | FileCheck %s -check-prefix=CHECK-LTO
+// CHECK-LTO: -cc1
+// CHECK-LTO: -emit-llvm-bc
+// CHECK-LTO-NOT: warning: argument unused during compilation: '-fembed-bitcode'
+// CHECK-LTO-NOT: -cc1
+// CHECK-LTO-NOT: -fembed-bitcode
+
+// RUN: %clang -c %s -fembed-bitcode-marker 2>&1 -### | FileCheck %s -check-prefix=CHECK-MARKER
+// CHECK-MARKER: -cc1
+// CHECK-MARKER: -emit-obj
+// CHECK-MARKER: -fembed-bitcode-marker
+// CHECK-MARKER-NOT: -cc1
+
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3620,6 +3620,17 @@
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
+  // Embed-bitcode option.
+  if (C.getDriver().embedBitcodeEnabled() &&
+  (isa(JA) || isa(JA))) {
+// Add flags implied by -fembed-bitcode.
+CmdArgs.push_back("-fembed-bitcode");
+// Disable all llvm IR level optimizations.
+CmdArgs.push_back("-disable-llvm-optzns");
+  }
+  if (C.getDriver().embedBitcodeMarkerOnly())
+CmdArgs.push_back("-fembed-bitcode-marker");
+
   // We normally speed up the clang process a bit by skipping destructors at
   // exit, but when we're generating diagnostics we can rely on some of the
   // cleanup.
@@ -7176,6 +7187,15 @@
 else
   CmdArgs.push_back("-no_pie");
   }
+  // for embed-bitcode, use -bitcode_bundle in linker command
+  if (C.getDriver().embedBitcodeEnabled() ||
+  C.getDriver().embedBitcodeMarkerOnly()) {
+// Check if the toolchain supports bitcode build flow.
+if (MachOTC.SupportsEmbeddedBitcode())
+  CmdArgs.push_back("-bitcode_bundle");
+else
+  D.Diag(diag::err_drv_bitcode_unsupported_on_toolchain);
+  }
 
   Args.AddLastArg(CmdArgs, options::OPT_prebind);
   Args.AddLastArg(CmdArgs, options::OPT_noprebind);
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -542,6 +542,8 @@
 
   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
 
+  bool SupportsEmbeddedBitcode() const override;
+
   SanitizerMask getSupportedSanitizers() const override;
 };
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1103,6 +1103,13 @@
   return !Triple.isWatchABI();
 }
 
+bool Darwin::SupportsEmbeddedBitcode() const {
+  assert(TargetInitialized && "Target not initialized!");
+  if (isTargetIPhoneOS() && isIPhoneOSVersionLT(6, 0))
+return false;
+  return true;
+}
+
 bool MachO::isPICDefault() const { return true; }
 
 bool MachO::isPIEDefault() const { return false; }
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -50,7 +50,7 @@
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr VFS)
 : Opts(createDriverOptTable()), Diags(Diags), VFS(VFS), Mode(GCCMode),
-  SaveTemps(SaveTempsNone), LTOMode(LTOK_None),
+  SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone), LTOMode(LTOK_None),
   ClangExecutable(ClangExecutable),
   SysRoot(DEFAULT_SYSROOT), UseStdLib(true),
   DefaultTargetTriple(DefaultTargetTriple),
@@ -479,6 +479,19 @@
 .Default(SaveTempsCwd);
   }
 
+  // Ignore -fembed-bitcode options with LTO
+  // since the output will be bitcode anyway.
+  if (!Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false)) {
+if (

Re: [PATCH] D17389: Embed bitcode in object file (clang cc1 part)

2016-02-18 Thread Steven Wu via cfe-commits
steven_wu abandoned this revision.
steven_wu added a comment.

I accidentally send this patch with everything in it. I will send out patch in 
small chunks instead.


http://reviews.llvm.org/D17389



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


[PATCH] D17392: Embed bitcode in object file (clang cc1 part)

2016-02-18 Thread Steven Wu via cfe-commits
steven_wu created this revision.
steven_wu added a subscriber: cfe-commits.
steven_wu added a dependency: D17390: Introduce -fembed-bitcode driver option.

Teach clang to embed bitcode inside bitcode. When -fembed-bitcode cc1
option is used, clang will embed both the input bitcode and cc1
commandline into the bitcode in special sections before compiling to
the object file.  Using -fembed-bitcode-marker will only introduce a
marker in both sections.

Depends on D17390

http://reviews.llvm.org/D17392

Files:
  include/clang/CodeGen/BackendUtil.h
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Frontend/embed-bitcode.ll

Index: test/Frontend/embed-bitcode.ll
===
--- /dev/null
+++ test/Frontend/embed-bitcode.ll
@@ -0,0 +1,48 @@
+; check .ll input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode -x ir %s -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode-marker -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+; RUN: %clang_cc1 -triple aarch64-unknown-linux-gnueabi -emit-llvm \
+; RUN:-fembed-bitcode -x ir %s -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-ELF
+
+; check .bc input
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-x ir %s -o %t.bc
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode -x ir %t.bc -o - \
+; RUN:| FileCheck %s
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode-marker -x ir %t.bc -o - \
+; RUN:| FileCheck %s -check-prefix=CHECK-MARKER
+
+; run through -fembed-bitcode twice and make sure it doesn't crash
+; RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm-bc \
+; RUN:-fembed-bitcode -x ir %s -o - \
+; RUN: | %clang_cc1 -triple thumbv7-apple-ios8.0.0 -emit-llvm \
+; RUN:-fembed-bitcode -x ir - -o /dev/null
+
+; check the magic number of bitcode at the beginning of the string
+; CHECK: @llvm.embedded.module
+; CHECK: c"\DE\C0\17\0B
+; CHECK: section "__LLVM,__bitcode"
+; CHECK: @llvm.cmdline
+; CHECK: section "__LLVM,__cmdline"
+
+; CHECK-ELF: @llvm.embedded.module
+; CHECK-ELF: section ".llvmbc"
+; CHECK-ELF: @llvm.cmdline
+; CHECK-ELF: section ".llvmcmd"
+
+; CHECK-MARKER: @llvm.embedded.module
+; CHECK-MARKER: constant [0 x i8] zeroinitializer
+; CHECK-MARKER: section "__LLVM,__bitcode"
+; CHECK-MARKER: @llvm.cmdline
+; CHECK-MARKER: section "__LLVM,__cmdline"
+
+define i32 @f0() {
+  ret i32 0
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -616,6 +616,34 @@
   }
 }
   }
+	// Handle -fembed-bitcode option.
+  Opts.EmbedBitcode = Args.hasArg(OPT_fembed_bitcode);
+  Opts.EmbedMarkerOnly = Args.hasArg(OPT_fembed_bitcode_marker);
+  // FIXME: For backend options that are not yet recorded as function
+  // attributes in the IR, keep track of them so we can embed them in a
+  // separate data section and use them when building the bitcode.
+  if (Opts.EmbedBitcode) {
+for (ArgList::const_iterator A = Args.begin(), AE = Args.end();
+ A != AE; ++ A) {
+  // Do not encode output and input.
+  if ((*A)->getOption().getID() == options::OPT_o ||
+  (*A)->getOption().getID() == options::OPT_INPUT ||
+  (*A)->getOption().getID() == options::OPT_x ||
+  (*A)->getOption().getID() == options::OPT_fembed_bitcode ||
+  ((*A)->getOption().getGroup().isValid() &&
+   (*A)->getOption().getGroup().getID() == options::OPT_W_Group))
+continue;
+  ArgStringList ASL;
+  (*A)->render(Args, ASL);
+  for (ArgStringList::iterator it = ASL.begin(), ie = ASL.end();
+  it != ie; ++ it) {
+StringRef ArgStr(*it);
+Opts.CmdArgs.insert(Opts.CmdArgs.end(), ArgStr.begin(), ArgStr.end());
+// using \00 to seperate each commandline options.
+Opts.CmdArgs.push_back('\0');
+  }
+}
+  }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5553,7 +5553,10 @@
   // With -save-temps, we want to save the unoptimized bitcode output from the
   // CompileJobAction, use -disable-llvm-passes to get pristine IR generated
   // by the frontend.
-  if (C.getDriver().isSaveTempsEnabled() && isa(JA))
+  // When -fembed-bitcode is enabled, optimized bitcode is emitted because it
+  // has slightly different breakdown between stages.
+  if (C.getDrive

[libcxx] r261231 - Split locale management out of newlib/xlocale.h. NFCI

2016-02-18 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Thu Feb 18 11:40:16 2016
New Revision: 261231

URL: http://llvm.org/viewvc/llvm-project?rev=261231&view=rev
Log:
Split locale management out of newlib/xlocale.h. NFCI

This is one part of many of a locale refactor. See
http://reviews.llvm.org/D17146 for an idea of where this is going.

For the locale refactor, the locale management functions (newlocale,
freelocale, uselocale) are needed in a separate header from the various _l
functions. This is because some platforms implement the _l functions in terms
of a locale switcher RAII helper, and the locale switcher RAII helper needs
the locale management functions. This patch helps pave the way by getting all
the functions in the right files, so that later diffs aren't completely
horrible.

The "do-nothing" / "nop" locale functions are also useful on their own for
other lightweight platforms. Putting these nop implementations in
support/xlocale should enable code sharing.

Unfortunately, I have no access to a newlib system to build and test with, so
this change has been made blind.

Reviewed: http://reviews.llvm.org/D17382

Added:
libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h
Modified:
libcxx/trunk/include/support/newlib/xlocale.h

Modified: libcxx/trunk/include/support/newlib/xlocale.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/newlib/xlocale.h?rev=261231&r1=261230&r2=261231&view=diff
==
--- libcxx/trunk/include/support/newlib/xlocale.h (original)
+++ libcxx/trunk/include/support/newlib/xlocale.h Thu Feb 18 11:40:16 2016
@@ -16,41 +16,12 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// Patch over newlib's lack of extended locale support
-typedef void *locale_t;
-static inline locale_t duplocale(locale_t) {
-  return NULL;
-}
-
-static inline void freelocale(locale_t) {
-}
-
-static inline locale_t newlocale(int, const char *, locale_t) {
-  return NULL;
-}
-
-static inline locale_t uselocale(locale_t) {
-  return NULL;
-}
-
-#define LC_COLLATE_MASK  (1 << LC_COLLATE)
-#define LC_CTYPE_MASK(1 << LC_CTYPE)
-#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
-#define LC_MONETARY_MASK (1 << LC_MONETARY)
-#define LC_NUMERIC_MASK  (1 << LC_NUMERIC)
-#define LC_TIME_MASK (1 << LC_TIME)
-#define LC_ALL_MASK (LC_COLLATE_MASK|\
- LC_CTYPE_MASK|\
- LC_MONETARY_MASK|\
- LC_NUMERIC_MASK|\
- LC_TIME_MASK|\
- LC_MESSAGES_MASK)
-
 // Share implementation with Android's Bionic
 #include 
 

Added: libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h?rev=261231&view=auto
==
--- libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h (added)
+++ libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h Thu Feb 18 
11:40:16 2016
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===  support/xlocale/__nop_locale_mgmt.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Patch over lack of extended locale support
+typedef void *locale_t;
+static inline locale_t duplocale(locale_t) {
+  return NULL;
+}
+
+static inline void freelocale(locale_t) {
+}
+
+static inline locale_t newlocale(int, const char *, locale_t) {
+  return NULL;
+}
+
+static inline locale_t uselocale(locale_t) {
+  return NULL;
+}
+
+#define LC_COLLATE_MASK  (1 << LC_COLLATE)
+#define LC_CTYPE_MASK(1 << LC_CTYPE)
+#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
+#define LC_MONETARY_MASK (1 << LC_MONETARY)
+#define LC_NUMERIC_MASK  (1 << LC_NUMERIC)
+#define LC_TIME_MASK (1 << LC_TIME)
+#define LC_ALL_MASK (LC_COLLATE_MASK|\
+ LC_CTYPE_MASK|\
+ LC_MONETARY_MASK|\
+ LC_NUMERIC_MASK|\
+ LC_TIME_MASK|\
+ LC_MESSAGES_MASK)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H


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


[libcxx] r261230 - Split locale management out of ibm/xlocale.h. NFCI

2016-02-18 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Thu Feb 18 11:37:33 2016
New Revision: 261230

URL: http://llvm.org/viewvc/llvm-project?rev=261230&view=rev
Log:
Split locale management out of ibm/xlocale.h. NFCI

This is one part of many of a locale refactor. See
http://reviews.llvm.org/D17146 for an idea of where this is going.

For the locale refactor, the locale management functions (newlocale,
freelocale, uselocale) are needed in a separate header from the various _l
functions. This is because some platforms implement the _l functions in terms
of a locale switcher RAII helper, and the locale switcher RAII helper needs
the locale management functions. This patch helps pave the way by getting all
the functions in the right files, so that later diffs aren't completely
horrible.

Unfortunately, I have no access to an AIX machine to build with, so this change
has been made blind. Also, the original author (Xing Xue) does not appear to
have a Phabricator account.

Reviewed: http://reviews.llvm.org/D17380

Added:
libcxx/trunk/include/support/ibm/locale_mgmt_aix.h
Modified:
libcxx/trunk/include/support/ibm/xlocale.h

Added: libcxx/trunk/include/support/ibm/locale_mgmt_aix.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/ibm/locale_mgmt_aix.h?rev=261230&view=auto
==
--- libcxx/trunk/include/support/ibm/locale_mgmt_aix.h (added)
+++ libcxx/trunk/include/support/ibm/locale_mgmt_aix.h Thu Feb 18 11:37:33 2016
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+//===--- support/ibm/locale_mgmt_aix.h 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
+#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H
+
+#if defined(_AIX)
+#include "cstdlib"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_AIX71)
+// AIX 7.1 and higher has these definitions.  Definitions and stubs
+// are provied here as a temporary workaround on AIX 6.1.
+
+#define LC_COLLATE_MASK 1
+#define LC_CTYPE_MASK   2
+#define LC_MESSAGES_MASK4
+#define LC_MONETARY_MASK8
+#define LC_NUMERIC_MASK 16
+#define LC_TIME_MASK32
+#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \
+ LC_MESSAGES_MASK | LC_MONETARY_MASK |\
+ LC_NUMERIC_MASK | LC_TIME_MASK)
+
+typedef void* locale_t;
+
+// The following are stubs.  They are not supported on AIX 6.1.
+static inline
+locale_t newlocale(int category_mask, const char *locale, locale_t base)
+{
+  _LC_locale_t *newloc, *loc;
+  if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL)
+  {
+errno = EINVAL;
+return (locale_t)0;
+  }
+  if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL)
+  {
+errno = ENOMEM;
+return (locale_t)0;
+  }
+  if (!base)
+base = (_LC_locale_t *)__xopen_locale("C");
+  memcpy(newloc, base, sizeof (_LC_locale_t));
+  if (category_mask & LC_COLLATE_MASK)
+newloc->lc_collate = loc->lc_collate;
+  if (category_mask & LC_CTYPE_MASK)
+newloc->lc_ctype = loc->lc_ctype;
+  //if (category_mask & LC_MESSAGES_MASK)
+  //  newloc->lc_messages = loc->lc_messages;
+  if (category_mask & LC_MONETARY_MASK)
+newloc->lc_monetary = loc->lc_monetary;
+  if (category_mask & LC_TIME_MASK)
+newloc->lc_time = loc->lc_time;
+  if (category_mask & LC_NUMERIC_MASK)
+newloc->lc_numeric = loc->lc_numeric;
+  return (locale_t)newloc;
+}
+static inline
+void freelocale(locale_t locobj)
+{
+  free(locobj);
+}
+static inline
+locale_t uselocale(locale_t newloc)
+{
+  return (locale_t)0;
+}
+#endif // !defined(_AIX71)
+
+#ifdef __cplusplus
+}
+#endif
+#endif // defined(_AIX)
+#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H

Modified: libcxx/trunk/include/support/ibm/xlocale.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/ibm/xlocale.h?rev=261230&r1=261229&r2=261230&view=diff
==
--- libcxx/trunk/include/support/ibm/xlocale.h (original)
+++ libcxx/trunk/include/support/ibm/xlocale.h Thu Feb 18 11:37:33 2016
@@ -10,6 +10,7 @@
 
 #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
 #define _LIBCPP_SUPPORT_IBM_XLOCALE_H
+#include 
 
 #if defined(_AIX)
 #include "cstdlib"
@@ -21,62 +22,6 @@ extern "C" {
 #if !defined(_AIX71)
 // AIX 7.1 and higher has these definitions.  Definitions and stubs
 // are provied here as a temporary workaround on AIX 6.1.
-
-#define LC_COLLATE_MASK 1
-#define LC_CTYPE_MASK   2
-#define LC_MESSAGES_MASK4
-#define LC_MONETARY_MASK8
-#define LC_NUMERIC_MASK 16
-#define LC_TIME_MASK32
-#define LC_AL

Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Manman Ren via cfe-commits
manmanren added a comment.



> If Capacity is not a multiple of 8, (LocalSize + NumBytesAtAlign4) % 8 
> doesn't tell you whether the new element will be 8-byte aligned. For example, 
> if Capacity==36, NumBytesAtAlign4==4, and LocalSize==8, (LocalSize + 
> NumBytesAtAlign4) equals 12 but padding is not needed as the new element can 
> start at Index=24.


I was reading the numbers wrong.

> Note that it's possible to have a Capacity that isn't a multiple of 8 by 
> calling TypeLocBuilder::reserve. I think padding is needed if the new index 
> (Index - LocalSize) is not a multiple of 8.


You are right, I missed the case where Capacity may not be 8-byte aligned.


http://reviews.llvm.org/D16843



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


Re: [PATCH] D16552: Implement the likely resolution of core issue 253.

2016-02-18 Thread Nico Weber via cfe-commits
thakis added inline comments.


Comment at: include/clang/AST/DeclCXX.h:410
@@ +409,3 @@
+};
+unsigned AllowConstDefaultInit : 3;
+AllowConstDefInitKind allowConstDefInitKind() {

This should be :2 of course.


http://reviews.llvm.org/D16552



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


Embedded Bitcode in Object Files

2016-02-18 Thread Steven Wu via cfe-commits
Hi all

I put up some patches for embedding bitcode inside the object file 
(-fembed-bitcode) option. As I described in the dev list before, the new option 
can create normal object file with bitcode embedded in a special section. You 
can easily recreate the same object file with the embedded bitcode in it.

I split the patch into several parts:
llvm patch:
http://reviews.llvm.org/D17388: Introduce the section for embedding bitcode in 
MachO file.

There are four clang patches:
http://reviews.llvm.org/D17390: Implementing the clang driver for the new 
option.
http://reviews.llvm.org/D17392: Teach clang how to embed bitcode into the 
object file.
http://reviews.llvm.org/D17393: Slightly tweak the bitcode emitted in embed 
bitcode stage 1.
http://reviews.llvm.org/D17394: Reduce the amount of option gets embedded in 
the bitcode by introducing a whitelist and a blacklist.

Let me know if anyone is interested in helping reviewing these changes.

Thanks

Steven



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


Re: [PATCH] D16012: Carry raw string literal information through to the AST StringLiteral representation

2016-02-18 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D16012#351827, @rsmith wrote:

> I'm definitely sympathetic to making `StringLiteralParser` expose information 
> [...]


I was unaware of this class; so far I have only studied the classes appearing 
in the AST.

I did notice that the AST shows string literals after concatenation (which 
makes perfect sense) and sometimes for refactoring you want to treat the 
individual string literal chunks separately.  My clang-tidy check for raw 
string literals is probably confused by literal concatenation in the AST, so I 
will go add some tests for those cases.

One area of clang-tidy/refactoring tooling code development that is pretty 
opaque at the moment is when you should dip down to relexing/reparsing the 
source text and when you use the AST.  So far most (all?) of the documentation 
on guiding developers to writing such tools talks almost exclusively about the 
AST.  Anything we can do to simplify lexing/parsing tasks when you need to dip 
lower than the AST would be most welcome.


http://reviews.llvm.org/D16012



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-02-18 Thread David Li via cfe-commits
davidxl added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:150
@@ -149,2 +149,3 @@
 
-  if (!CodeGenOpts.InstrProfileInput.empty()) {
+  if (!CodeGenOpts.hasProfileIRInstr() &&
+  !CodeGenOpts.InstrProfileInput.empty()) {

Better to use if (CodeGenOpts.hasProfileClangInstr() && ..)


Comment at: lib/Driver/Tools.cpp:3201
@@ +3200,3 @@
+// Set the profile kind if it's not the default clang kind.
+static void setProfileKindFlag(ArgStringList &CmdArgs,
+   std::string ProfileName) {

I don't quite like this change in the driver. I think the right thing to do is:

1) for profile use case, there is no need to pass -fprofile-instrument=<...> FE 
option from the driver
2) The profileInstrKind determination needs to happen in FE (not driver) by 
peeking into the passed in profile data.


http://reviews.llvm.org/D15829



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


[PATCH] D17397: Make deprecation message for -fsanitize-coverage= with numeric argument friendlier.

2016-02-18 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: kcc.
thakis added a subscriber: cfe-commits.

http://reviews.llvm.org/D17397

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/fsanitize-coverage.c

Index: test/Driver/fsanitize-coverage.c
===
--- test/Driver/fsanitize-coverage.c
+++ test/Driver/fsanitize-coverage.c
@@ -22,7 +22,7 @@
 // CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-indirect-calls
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=3 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-3
-// CHECK-SANITIZE-COVERAGE-3: warning: argument '-fsanitize-coverage=3' is 
deprecated, use '-fsanitize-coverage=[func,bb,edge]' instead
+// CHECK-SANITIZE-COVERAGE-3: warning: argument '-fsanitize-coverage=3' is 
deprecated, use '-fsanitize-coverage=edge' instead
 //
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=5 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-5
 // CHECK-SANITIZE-COVERAGE-5: error: unsupported argument '5' to option 
'fsanitize-coverage='
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -444,23 +444,31 @@
   !StringRef(Arg->getValue(0))
.getAsInteger(0, LegacySanitizeCoverage) &&
   LegacySanitizeCoverage >= 0 && LegacySanitizeCoverage <= 4) {
-D.Diag(diag::warn_drv_deprecated_arg)
-<< Arg->getAsString(Args) << "-fsanitize-coverage=[func,bb,edge]";
-// TODO: Add deprecation notice for this form.
 switch (LegacySanitizeCoverage) {
 case 0:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=";
   CoverageFeatures = 0;
   break;
 case 1:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=func";
   CoverageFeatures = CoverageFunc;
   break;
 case 2:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=bb";
   CoverageFeatures = CoverageBB;
   break;
 case 3:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=edge";
   CoverageFeatures = CoverageEdge;
   break;
 case 4:
+  D.Diag(diag::warn_drv_deprecated_arg)
+  << Arg->getAsString(Args)
+  << "-fsanitize-coverage=edge,indirect-calls";
   CoverageFeatures = CoverageEdge | CoverageIndirCall;
   break;
 }


Index: test/Driver/fsanitize-coverage.c
===
--- test/Driver/fsanitize-coverage.c
+++ test/Driver/fsanitize-coverage.c
@@ -22,7 +22,7 @@
 // CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-indirect-calls
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=3 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-3
-// CHECK-SANITIZE-COVERAGE-3: warning: argument '-fsanitize-coverage=3' is deprecated, use '-fsanitize-coverage=[func,bb,edge]' instead
+// CHECK-SANITIZE-COVERAGE-3: warning: argument '-fsanitize-coverage=3' is deprecated, use '-fsanitize-coverage=edge' instead
 //
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=5 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-5
 // CHECK-SANITIZE-COVERAGE-5: error: unsupported argument '5' to option 'fsanitize-coverage='
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -444,23 +444,31 @@
   !StringRef(Arg->getValue(0))
.getAsInteger(0, LegacySanitizeCoverage) &&
   LegacySanitizeCoverage >= 0 && LegacySanitizeCoverage <= 4) {
-D.Diag(diag::warn_drv_deprecated_arg)
-<< Arg->getAsString(Args) << "-fsanitize-coverage=[func,bb,edge]";
-// TODO: Add deprecation notice for this form.
 switch (LegacySanitizeCoverage) {
 case 0:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=";
   CoverageFeatures = 0;
   break;
 case 1:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=func";
   CoverageFeatures = CoverageFunc;
   break;
 case 2:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Ar

Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-18 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

@Mats, I think I would prefer not to add even more special handling (i.e. error 
in this case) for printf.

I will look into adding it as a Builtin instead. However, I would prefer to 
remove it from this change and submit a separate patch as it doesn't belong to 
Clang blocks anyways.

Thanks!


http://reviews.llvm.org/D16928



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


Re: [PATCH] D17349: ARM: fix VFP asm constraints

2016-02-18 Thread JF Bastien via cfe-commits
jfb updated this revision to Diff 48363.
jfb added a comment.

- Add test.


http://reviews.llvm.org/D17349

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-vfp-asm-constraint.c

Index: test/CodeGen/arm-vfp-asm-constraint.c
===
--- /dev/null
+++ test/CodeGen/arm-vfp-asm-constraint.c
@@ -0,0 +1,36 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv7-unknown-unknown -mfpmath vfp -emit-llvm -o - 
%s | FileCheck %s
+
+// CHECK-NOT: error:
+
+double fabs(double x) { // CHECK-LABEL: @fabs(
+  // CHECK: call double asm "vabs.f64 ${0:P}, ${1:P}", "=w,w"(double
+  __asm__("vabs.f64 %P0, %P1"
+  : "=w"(x)
+  : "w"(x));
+  return x;
+}
+
+float fabsf(float x) { // CHECK-LABEL: @fabsf(
+  // CHECK: call float asm "vabs.f32 $0, $1", "=t,t"(float
+  __asm__("vabs.f32 %0, %1"
+  : "=t"(x)
+  : "t"(x));
+  return x;
+}
+
+double sqrt(double x) { // CHECK-LABEL: @sqrt(
+  // CHECK: call double asm "vsqrt.f64 ${0:P}, ${1:P}", "=w,w"(double
+  __asm__("vsqrt.f64 %P0, %P1"
+  : "=w"(x)
+  : "w"(x));
+  return x;
+}
+
+float sqrtf(float x) { // CHECK-LABEL: @sqrtf(
+  // CHECK: call float asm "vsqrt.f32 $0, $1", "=t,t"(float
+  __asm__("vsqrt.f32 %0, %1"
+  : "=t"(x)
+  : "t"(x));
+  return x;
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4939,8 +4939,8 @@
 default: break;
 case 'l': // r0-r7
 case 'h': // r8-r15
-case 'w': // VFP Floating point register single precision
-case 'P': // VFP Floating point register double precision
+case 't': // VFP Floating point register single precision
+case 'w': // VFP Floating point register double precision
   Info.setAllowsRegister();
   return true;
 case 'I':


Index: test/CodeGen/arm-vfp-asm-constraint.c
===
--- /dev/null
+++ test/CodeGen/arm-vfp-asm-constraint.c
@@ -0,0 +1,36 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv7-unknown-unknown -mfpmath vfp -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-NOT: error:
+
+double fabs(double x) { // CHECK-LABEL: @fabs(
+  // CHECK: call double asm "vabs.f64 ${0:P}, ${1:P}", "=w,w"(double
+  __asm__("vabs.f64 %P0, %P1"
+  : "=w"(x)
+  : "w"(x));
+  return x;
+}
+
+float fabsf(float x) { // CHECK-LABEL: @fabsf(
+  // CHECK: call float asm "vabs.f32 $0, $1", "=t,t"(float
+  __asm__("vabs.f32 %0, %1"
+  : "=t"(x)
+  : "t"(x));
+  return x;
+}
+
+double sqrt(double x) { // CHECK-LABEL: @sqrt(
+  // CHECK: call double asm "vsqrt.f64 ${0:P}, ${1:P}", "=w,w"(double
+  __asm__("vsqrt.f64 %P0, %P1"
+  : "=w"(x)
+  : "w"(x));
+  return x;
+}
+
+float sqrtf(float x) { // CHECK-LABEL: @sqrtf(
+  // CHECK: call float asm "vsqrt.f32 $0, $1", "=t,t"(float
+  __asm__("vsqrt.f32 %0, %1"
+  : "=t"(x)
+  : "t"(x));
+  return x;
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4939,8 +4939,8 @@
 default: break;
 case 'l': // r0-r7
 case 'h': // r8-r15
-case 'w': // VFP Floating point register single precision
-case 'P': // VFP Floating point register double precision
+case 't': // VFP Floating point register single precision
+case 'w': // VFP Floating point register double precision
   Info.setAllowsRegister();
   return true;
 case 'I':
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17397: Make deprecation message for -fsanitize-coverage= with numeric argument friendlier.

2016-02-18 Thread Kostya Serebryany via cfe-commits
kcc accepted this revision.
kcc added a comment.
This revision is now accepted and ready to land.

LGTM
Thanks! 
I don't see much value in doing this, but also don't mind.


http://reviews.llvm.org/D17397



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


Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-02-18 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the feedback!



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3901-3932
@@ +3900,34 @@
+// Reference types are ignored for mapping purposes.
+if (auto *RefTy = ExprTy->getAs())
+  ExprTy = RefTy->getPointeeType().getCanonicalType();
+
+// Given that an array section is considered a built-in type, we need to
+// do the calculation based on the length of the section instead of relying
+// on CGF.getTypeSize(E->getType()).
+if (const auto *OAE = dyn_cast(E)) {
+  auto BaseTy =
+  OAE->getBase()->IgnoreParenImpCasts()->getType().getCanonicalType();
+  // Reference types are ignored for mapping purposes.
+  if (auto *RefTy = BaseTy->getAs())
+BaseTy = RefTy->getPointeeType().getCanonicalType();
+
+  // If there is no length associated with the expression, that means we
+  // are using the whole length of the base.
+  if (!OAE->getLength())
+return CGF.getTypeSize(BaseTy);
+
+  llvm::Value *ElemSize;
+  if (auto *PTy = BaseTy->getAs()) {
+ElemSize = CGF.getTypeSize(PTy->getPointeeType().getCanonicalType());
+  } else {
+auto *ATy = cast(BaseTy.getTypePtr());
+assert(ATy && "Expecting array type if not a pointer type.");
+ElemSize = CGF.getTypeSize(ATy->getElementType().getCanonicalType());
+  }
+
+  auto *LengthVal = CGF.EmitScalarExpr(OAE->getLength());
+  LengthVal =
+  CGF.Builder.CreateIntCast(LengthVal, CGF.SizeTy, /*isSigned=*/false);
+  return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
+}
+return CGF.getTypeSize(ExprTy);

ABataev wrote:
> Did not find any with array sections as base. Could please point a test where 
> I can find something like 'marr[:][0:2][0:2]' as a mapped expression?
> Also, it will produce some recalculation for VLAs. Add a test for it, please.
> Did not find any with array sections as base. Could please point a test where 
> I can find something like 'marr[:][0:2][0:2]' as a mapped expression?

Oh, a map that uses an array expression that is not in the rightmost 
subexpression is illegal because it would correspond to non-contiguous storage. 
Sema is already taking care of that. I added your specific example to the Sema 
tests anyway.

> Also, it will produce some recalculation for VLAs. Add a test for it, please.

Added tests for multidimensional VLAs.







http://reviews.llvm.org/D16749



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


Re: [PATCH] D16552: Implement the likely resolution of core issue 253.

2016-02-18 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/DeclCXX.h:405-416
@@ -404,1 +404,14 @@
 
+enum AllowConstDefInitKind {
+   ACDI_Unknown,
+   ACDI_Yes,
+   ACDI_No,
+};
+unsigned AllowConstDefaultInit : 3;
+AllowConstDefInitKind allowConstDefInitKind() {
+  return static_cast(AllowConstDefaultInit);
+}
+void setAllowConstDefInitKind(AllowConstDefInitKind Allow) {
+  AllowConstDefaultInit = Allow;
+}
+

Is it worth caching this? (If so, the bit-field should occupy at most 2 bits...)


Comment at: include/clang/AST/DeclCXX.h:1286
@@ -1272,1 +1285,3 @@
 
+  /// \brief Determine whether declaring a const with this type is ok per
+  /// core issue 253.

Declaring a const what?


Comment at: lib/AST/DeclCXX.cpp:396-425
@@ -394,1 +395,32 @@
 
+bool CXXRecordDecl::allowConstDefaultInitSlow() const {
+  assert(getDefinition() && "only call this on completed records");
+  if (hasUserProvidedDefaultConstructor()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_Yes);
+return true;
+  }
+  for (const auto *F : fields()) {
+if (F->hasInClassInitializer() || F->isUnnamedBitfield())
+  continue;
+if (CXXRecordDecl *FieldType = F->getType()->getAsCXXRecordDecl()) {
+  if (!FieldType->allowConstDefaultInit()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+return false;
+  }
+} else {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }
+  for (const auto& BI : bases()) {
+const RecordType *RT = BI.getType()->getAs();
+CXXRecordDecl *Base = cast(RT->getDecl());
+if (!Base->allowConstDefaultInit()) {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_Yes);
+  return true;
+}
+

For all the other fields of this kind, we compute the flag as bases and members 
are added to the class. It seems like we can do the same here, and all else 
being equal, it would be better to not deviate from the existing pattern 
without good reason.

The most natural way to do this would probably be to store a single flag for 
`HasUninitializedFields`, and then compute whether default initialization would 
leave a field uninitialized as `!hasUserProvidedDefaultConstructor() && 
HasUninitializedFields`.


Comment at: lib/AST/DeclCXX.cpp:403-413
@@ +402,13 @@
+  for (const auto *F : fields()) {
+if (F->hasInClassInitializer() || F->isUnnamedBitfield())
+  continue;
+if (CXXRecordDecl *FieldType = F->getType()->getAsCXXRecordDecl()) {
+  if (!FieldType->allowConstDefaultInit()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+return false;
+  }
+} else {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }

I think you should skip `mutable` members here, as the corresponding subobject 
of a `const` object is not itself `const`.


http://reviews.llvm.org/D16552



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


Re: [PATCH] D17148: [OPENMP] Basic teams directive implementation

2016-02-18 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked 4 inline comments as done.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4426-4431
@@ +4425,8 @@
+ SourceLocation Loc) {
+  llvm::Value *PushNumTeamsArgs[] = {
+  emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc), NumTeams,
+  ThreadLimit};
+  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_push_num_teams),
+  PushNumTeamsArgs);
+
+  if (!CGF.HaveInsertPoint())

ABataev wrote:
> What is this? Copy-paste?
Yes, it is - sorry!


Repository:
  rL LLVM

http://reviews.llvm.org/D17148



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


Re: [PATCH] D17148: [OPENMP] Basic teams directive implementation

2016-02-18 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 48369.
carlo.bertolli added a comment.

Addressed latest comments.


Repository:
  rL LLVM

http://reviews.llvm.org/D17148

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/teams_codegen.cpp

Index: test/OpenMP/teams_codegen.cpp
===
--- test/OpenMP/teams_codegen.cpp
+++ test/OpenMP/teams_codegen.cpp
@@ -208,4 +208,139 @@
 
 }
 #endif // CK3
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -DCK4 -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 -DCK4 -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 CK4 --check-prefix CK4-64
+// RUN: %clang_cc1 -DCK4 -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 -DCK4 -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 CK4 --check-prefix CK4-64
+// RUN: %clang_cc1 -DCK4 -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 -DCK4 -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 CK4 --check-prefix CK4-32
+// RUN: %clang_cc1 -DCK4 -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 -DCK4 -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 CK4 --check-prefix CK4-32
+
+#ifdef CK4
+
+// CK4-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CK4-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CK4-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+// CK4-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}teams_codegen.cpp;main;[[@LINE+14]];9;;\00"
+// CK4-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}teams_codegen.cpp;tmain;[[@LINE+7]];9;;\00"
+
+template 
+int tmain(T argc) {
+#pragma omp target
+#pragma omp teams
+  argc = 0;
+  return 0;
+}
+
+int main (int argc, char **argv) {
+#pragma omp target
+#pragma omp teams
+  argc = 0;
+  return tmain(argv);
+}
+
+// CK4:  define {{.*}}void @{{[^,]+}}(i{{.+}} %[[ARGC:.+]])
+// CK4:  [[ARGCADDR:%.+]] = alloca i{{.+}}
+// CK4:  store i{{.+}} %[[ARGC]], i{{.+}}* [[ARGCADDR]]
+// CK4-64:  [[CONV:%.+]] = bitcast i64* [[ARGCADDR]] to i32*
+// CK4-64:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* {{.+}} to void (i32*, i32*, ...)*), i32* [[CONV]])
+// CK4-32:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* {{.+}} to void (i32*, i32*, ...)*), i32* [[ARGCADDR]])
+// CK4:  ret void
+// CK4-NEXT: }
+
+// CK4:  define {{.*}}void @{{[^,]+}}(i8*** dereferenceable({{.}}) [[ARGC1:%.+]])
+// CK4:  [[ARGCADDR1:%.+]] = alloca i8***
+// CK4:  store i8*** [[ARGC1]], i8 [[ARGCADDR1]]
+// CK4:  [[CONV1:%.+]] = load i8***, i8 [[ARGCADDR1]]
+// CK4:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_teams(%ident_t* [[DEF_LOC_0]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* {{.+}} to void (i32*, i32*, ...)*), i8*** [[CONV1]])
+
+
+#endif // CK4
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -DCK5 -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 -DCK5 -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 CK5 --check-prefix CK5-64
+// RUN: %clang_cc1 -DCK5 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -em

Re: [PATCH] D17349: ARM: fix VFP asm constraints

2016-02-18 Thread JF Bastien via cfe-commits
jfb added a comment.

Added a test.

Constraint validation is lacking in LLVM: it doesn't check that the input 
variable matches the constraint. I do pass `mfpmath vfp` to the test in case 
this gets fixed, but it's not strictly necessary right now.

The following is currently accepted:

  int oops(int x) { // CHECK-LABEL: @oops(
// CHECK: call float asm "vsqrt.f32 $0, $1", "=t,t"(float
__asm__("vsqrt.f32 %0, %1"
: "=t"(x)
: "t"(x));
return x;
  }

Bitcode:

  define arm_aapcscc i32 @oops(i32 %x) #1 {
%1 = alloca i32, align 4
store i32 %x, i32* %1, align 4
%2 = load i32, i32* %1, align 4
%3 = call i32 asm "vsqrt.f32 $0, $1", "=t,t"(i32 %2) #2, !srcloc !7
store i32 %3, i32* %1, align 4
%4 = load i32, i32* %1, align 4
ret i32 %4
  }

Here's a fun GCC comparison , which is also surprising 
in a different way.

Fixing this would be an entirely different patch.


http://reviews.llvm.org/D17349



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


r261243 - [analyzer] Improve modeling of ObjC synthesized property setters.

2016-02-18 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Feb 18 13:13:30 2016
New Revision: 261243

URL: http://llvm.org/viewvc/llvm-project?rev=261243&view=rev
Log:
[analyzer] Improve modeling of ObjC synthesized property setters.

When modeling a call to a setter for a property that is synthesized to be
backed by an instance variable, don't invalidate the entire instance
but rather only the storage for the updated instance variable itself.

This still doesn't model the effect of the setter completely. It doesn't
bind the set value to the ivar storage location because doing so would cause
the set value to escape, removing valuable diagnostics about potential
leaks of the value from the retain count checker.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/properties.m

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=261243&r1=261242&r2=261243&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Thu 
Feb 18 13:13:30 2016
@@ -957,6 +957,11 @@ public:
 llvm_unreachable("Unknown message kind");
   }
 
+  // Returns the property accessed by this method, either explicitly via
+  // property syntax or implicitly via a getter or setter method. Returns
+  // nullptr if the call is not a prooperty access.
+  const ObjCPropertyDecl *getAccessedProperty() const;
+
   RuntimeDefinition getRuntimeDefinition() const override;
 
   bool argumentsMayEscape() const override;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=261243&r1=261242&r2=261243&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Thu Feb 18 13:13:30 2016
@@ -678,9 +678,26 @@ ArrayRef ObjCMethodCall::p
   return D->parameters();
 }
 
-void
-ObjCMethodCall::getExtraInvalidatedValues(ValueList &Values,
-  RegionAndSymbolInvalidationTraits *ETraits) const {
+void ObjCMethodCall::getExtraInvalidatedValues(
+ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const {
+
+  // If the method call is a setter for property known to be backed by
+  // an instance variable, don't invalidate the entire receiver, just
+  // the storage for that instance variable.
+  if (const ObjCPropertyDecl *PropDecl = getAccessedProperty()) {
+if (const ObjCIvarDecl *PropIvar = PropDecl->getPropertyIvarDecl()) {
+  SVal IvarLVal = getState()->getLValue(PropIvar, getReceiverSVal());
+  const MemRegion *IvarRegion = IvarLVal.getAsRegion();
+  ETraits->setTrait(
+  IvarRegion,
+  RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
+  ETraits->setTrait(IvarRegion,
+RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
+  Values.push_back(IvarLVal);
+  return;
+}
+  }
+
   Values.push_back(getReceiverSVal());
 }
 
@@ -740,6 +757,18 @@ const PseudoObjectExpr *ObjCMethodCall::
   return ObjCMessageDataTy::getFromOpaqueValue(Data).getPointer();
 }
 
+static const Expr *
+getSyntacticFromForPseudoObjectExpr(const PseudoObjectExpr *POE) {
+  const Expr *Syntactic = POE->getSyntacticForm();
+
+  // This handles the funny case of assigning to the result of a getter.
+  // This can happen if the getter returns a non-const reference.
+  if (const BinaryOperator *BO = dyn_cast(Syntactic))
+Syntactic = BO->getLHS();
+
+  return Syntactic;
+}
+
 ObjCMessageKind ObjCMethodCall::getMessageKind() const {
   if (!Data) {
 
@@ -749,12 +778,7 @@ ObjCMessageKind ObjCMethodCall::getMessa
 
 // Check if parent is a PseudoObjectExpr.
 if (const PseudoObjectExpr *POE = dyn_cast_or_null(S)) {
-  const Expr *Syntactic = POE->getSyntacticForm();
-
-  // This handles the funny case of assigning to the result of a getter.
-  // This can happen if the getter returns a non-const reference.
-  if (const BinaryOperator *BO = dyn_cast(Syntactic))
-Syntactic = BO->getLHS();
+  const Expr *Syntactic = getSyntacticFromForPseudoObjectExpr(POE);
 
   ObjCMessageKind K;
   switch (Syntactic->getStmtClass()) {
@@ -790,6 +814,27 @@ ObjCMessageKind ObjCMethodCall::getMessa
   return static_cast(Info.getInt());
 }
 
+const ObjCPropertyDecl *ObjCMethodCall::getAccessedProperty() const {
+  // Look for properties accessed with property syntax (foo.bar = ...)
+  if ( getMessageKind() == OCM_PropertyAccess) {
+const PseudoObjectExpr *POE = getContainingPseudoObjectExpr();
+assert(PO

Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-02-18 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3901-3932
@@ +3900,34 @@
+// Reference types are ignored for mapping purposes.
+if (auto *RefTy = ExprTy->getAs())
+  ExprTy = RefTy->getPointeeType().getCanonicalType();
+
+// Given that an array section is considered a built-in type, we need to
+// do the calculation based on the length of the section instead of relying
+// on CGF.getTypeSize(E->getType()).
+if (const auto *OAE = dyn_cast(E)) {
+  auto BaseTy =
+  OAE->getBase()->IgnoreParenImpCasts()->getType().getCanonicalType();
+  // Reference types are ignored for mapping purposes.
+  if (auto *RefTy = BaseTy->getAs())
+BaseTy = RefTy->getPointeeType().getCanonicalType();
+
+  // If there is no length associated with the expression, that means we
+  // are using the whole length of the base.
+  if (!OAE->getLength())
+return CGF.getTypeSize(BaseTy);
+
+  llvm::Value *ElemSize;
+  if (auto *PTy = BaseTy->getAs()) {
+ElemSize = CGF.getTypeSize(PTy->getPointeeType().getCanonicalType());
+  } else {
+auto *ATy = cast(BaseTy.getTypePtr());
+assert(ATy && "Expecting array type if not a pointer type.");
+ElemSize = CGF.getTypeSize(ATy->getElementType().getCanonicalType());
+  }
+
+  auto *LengthVal = CGF.EmitScalarExpr(OAE->getLength());
+  LengthVal =
+  CGF.Builder.CreateIntCast(LengthVal, CGF.SizeTy, /*isSigned=*/false);
+  return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
+}
+return CGF.getTypeSize(ExprTy);

'marr[:][:][:2]' produces contiguous storage, no? Is this allowed? And if it is 
allowed, how it will be handled? Besides, if 'marr' is a pointer, even 
'marr[:2][:3][:4]' may result in contiguous space.


http://reviews.llvm.org/D16749



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


Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-02-18 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3799-3806
@@ -3780,4 +3798,10 @@
   OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// \brief Emit the num_teams clause of an enclosed teams directive at the
+/// target region scope. If there is no teams directive associated with the
+/// target directive, or if there is no num_teams clause associated with the
+/// enclosed teams directive, return nullptr.
+static llvm::Value *
+emitNumTeamsClauseForTargetDirective(CodeGenFunction &CGF,

sfantao wrote:
> ABataev wrote:
> > I don't understand why global var is not captured in target region. If it 
> > is not implemented yet, it must be implemented. If it is not captured, it 
> > must be captured in Sema. We should not introduce some function/other 
> > objects to find a workaround for 'not implemented' features.
> Sorry, I was not clear in my comment. It is not that globals are not captured 
> in target regions - they are, we already have Sema doing that. 
> 
> My point is that exactly because we capture globals in target regions the 
> magic that `OMPCapturedExprDecl` introduces does not work for that specific 
> case. So, if we have something like:
> 
> ```
> int Gbl;
> 
> foo() {
>   #pragma omp target
>   #pragma omp teams num_teams(Gbl)
>   {}
> }
> ```
> when the DeclRefExpr for Gbl used in num_teams is emitted in the scope that 
> encloses '#pragma omp target', it will crash because Gbl is not a local and 
> is marked as refer to enclosing capture. 
> 
> If I got it right, a solution based on `OMPCapturedExprDecl` basically makes 
> local declarations whose initializers are the expression we are interested 
> in. In the cases that  `OMPCapturedExprDecl` is currently employed we don't 
> have globals being captured and that is why it works fine.
> 
> It is likely I am missing something here. Let me know if you need me to 
> provide more details.
> 
> Thanks!
It should not crash, because if it is captured, we must use captured version of 
this variable, passed in arguments to outlined function


http://reviews.llvm.org/D17019



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


Re: [PATCH] D16552: Implement the likely resolution of core issue 253.

2016-02-18 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 48373.
thakis marked an inline comment as done.
thakis added a comment.

address comments


http://reviews.llvm.org/D16552

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
  test/CXX/dcl.decl/dcl.init/p6.cpp
  test/SemaCXX/attr-selectany.cpp
  test/SemaCXX/constexpr-value-init.cpp
  test/SemaCXX/cxx0x-cursory-default-delete.cpp
  test/SemaCXX/illegal-member-initialization.cpp

Index: test/SemaCXX/illegal-member-initialization.cpp
===
--- test/SemaCXX/illegal-member-initialization.cpp
+++ test/SemaCXX/illegal-member-initialization.cpp
@@ -7,6 +7,7 @@
 };
 
 struct B {
+  int field;
 };
 
 struct X {
Index: test/SemaCXX/cxx0x-cursory-default-delete.cpp
===
--- test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -11,6 +11,7 @@
   non_const_copy& operator = (non_const_copy&) &;
   non_const_copy& operator = (non_const_copy&) &&;
   non_const_copy() = default; // expected-note {{not viable}}
+  int uninit_field;
 };
 non_const_copy::non_const_copy(non_const_copy&) = default; // expected-note {{not viable}}
 non_const_copy& non_const_copy::operator = (non_const_copy&) & = default; // expected-note {{not viable}}
@@ -30,6 +31,65 @@
   ncc = cncc; // expected-error {{no viable overloaded}}
 };
 
+struct no_fields { };
+struct all_init {
+  int a = 0;
+  int b = 0;
+};
+struct some_init {
+  int a = 0;
+  int b;
+  int c = 0;
+};
+struct some_init_mutable {
+  int a = 0;
+  mutable int b;
+  int c = 0;
+};
+struct some_init_def {
+  some_init_def() = default;
+  int a = 0;
+  int b;
+  int c = 0;
+};
+struct some_init_ctor {
+  some_init_ctor();
+  int a = 0;
+  int b;
+  int c = 0;
+};
+struct sub_some_init : public some_init_def { };
+struct sub_some_init_ctor : public some_init_def {
+  sub_some_init_ctor();
+};
+struct sub_some_init_ctor2 : public some_init_ctor {
+};
+struct some_init_container {
+  some_init_def sid;
+};
+struct some_init_container_ctor {
+  some_init_container_ctor();
+  some_init_def sid;
+};
+struct no_fields_container {
+  no_fields nf;
+};
+
+void constobjs() {
+  const no_fields nf; // ok
+  const all_init ai; // ok
+  const some_init si; // expected-error {{default initialization of an object of const type 'const some_init' without a user-provided default constructor}}
+  const some_init_mutable sim; // ok
+  const some_init_def sid; // expected-error {{default initialization of an object of const type 'const some_init_def' without a user-provided default constructor}}
+  const some_init_ctor sic; // ok
+  const sub_some_init ssi; // expected-error {{default initialization of an object of const type 'const sub_some_init' without a user-provided default constructor}}
+  const sub_some_init_ctor ssic; // ok
+  const sub_some_init_ctor2 ssic2; // ok
+  const some_init_container sicon; // expected-error {{default initialization of an object of const type 'const some_init_container' without a user-provided default constructor}}
+  const some_init_container_ctor siconc; // ok
+  const no_fields_container nfc; // ok
+}
+
 struct non_const_derived : non_const_copy {
   non_const_derived(const non_const_derived&) = default; // expected-error {{requires it to be non-const}}
   non_const_derived& operator =(non_const_derived&) = default;
Index: test/SemaCXX/constexpr-value-init.cpp
===
--- test/SemaCXX/constexpr-value-init.cpp
+++ test/SemaCXX/constexpr-value-init.cpp
@@ -14,7 +14,7 @@
   constexpr A a; // expected-error {{constant expression}} expected-note {{in call to 'A()'}}
 }
 
-constexpr B b1; // expected-error {{without a user-provided default constructor}}
+constexpr B b1; // ok
 constexpr B b2 = B(); // ok
 static_assert(b2.a.a == 1, "");
 static_assert(b2.a.b == 2, "");
Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -39,7 +39,9 @@
 // The D3D11 headers do something like this.  MSVC doesn't error on this at
 // all, even without the __declspec(selectany), in violation of the standard.
 // We fall back to a warning for selectany to accept headers.
-struct SomeStruct {};
+struct SomeStruct {
+  int foo;
+};
 extern const __declspec(selectany) SomeStruct some_struct; // expected-warning {{default initialization of an object of const type 'const SomeStruct' without a user-provided default constructor is a Microsoft extension}}
 
 // It should be possible to redeclare variables that were defined
Index: test/CXX/dcl.decl/dcl.init/p6.cpp
=

Re: [PATCH] D16552: Implement the likely resolution of core issue 253.

2016-02-18 Thread Nico Weber via cfe-commits
thakis added a comment.

thanks!



Comment at: include/clang/AST/DeclCXX.h:405-416
@@ -404,1 +404,14 @@
 
+enum AllowConstDefInitKind {
+   ACDI_Unknown,
+   ACDI_Yes,
+   ACDI_No,
+};
+unsigned AllowConstDefaultInit : 3;
+AllowConstDefInitKind allowConstDefInitKind() {
+  return static_cast(AllowConstDefaultInit);
+}
+void setAllowConstDefInitKind(AllowConstDefInitKind Allow) {
+  AllowConstDefaultInit = Allow;
+}
+

rsmith wrote:
> Is it worth caching this? (If so, the bit-field should occupy at most 2 
> bits...)
The motivation is that a chain of

struct A0 {};
struct A1 {  const A0 a; }
struct A2 {  const A1 a; }
struct A3 {  const A2 a; }

needs O(n^2) without caching. Changed the bitfield to 2 bits.


Comment at: include/clang/AST/DeclCXX.h:1286
@@ -1272,1 +1285,3 @@
 
+  /// \brief Determine whether declaring a const with this type is ok per
+  /// core issue 253.

rsmith wrote:
> Declaring a const what?
Done (I think?)


Comment at: lib/AST/DeclCXX.cpp:396-425
@@ -394,1 +395,32 @@
 
+bool CXXRecordDecl::allowConstDefaultInitSlow() const {
+  assert(getDefinition() && "only call this on completed records");
+  if (hasUserProvidedDefaultConstructor()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_Yes);
+return true;
+  }
+  for (const auto *F : fields()) {
+if (F->hasInClassInitializer() || F->isUnnamedBitfield())
+  continue;
+if (CXXRecordDecl *FieldType = F->getType()->getAsCXXRecordDecl()) {
+  if (!FieldType->allowConstDefaultInit()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+return false;
+  }
+} else {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }
+  for (const auto& BI : bases()) {
+const RecordType *RT = BI.getType()->getAs();
+CXXRecordDecl *Base = cast(RT->getDecl());
+if (!Base->allowConstDefaultInit()) {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_Yes);
+  return true;
+}
+

rsmith wrote:
> For all the other fields of this kind, we compute the flag as bases and 
> members are added to the class. It seems like we can do the same here, and 
> all else being equal, it would be better to not deviate from the existing 
> pattern without good reason.
> 
> The most natural way to do this would probably be to store a single flag for 
> `HasUninitializedFields`, and then compute whether default initialization 
> would leave a field uninitialized as `!hasUserProvidedDefaultConstructor() && 
> HasUninitializedFields`.
My reasoning here was that for the vast majority of types, we'll never have a 
const variable of that type, so computing this for all types seemed like a 
waste.


http://reviews.llvm.org/D16552



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


Re: [PATCH] D16552: Implement the likely resolution of core issue 253.

2016-02-18 Thread Nico Weber via cfe-commits
thakis added inline comments.


Comment at: lib/AST/DeclCXX.cpp:403-413
@@ +402,13 @@
+  for (const auto *F : fields()) {
+if (F->hasInClassInitializer() || F->isMutable() || F->isUnnamedBitfield())
+  continue;
+if (CXXRecordDecl *FieldType = F->getType()->getAsCXXRecordDecl()) {
+  if (!FieldType->allowConstDefaultInit()) {
+data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+return false;
+  }
+} else {
+  data().setAllowConstDefInitKind(DefinitionData::ACDI_No);
+  return false;
+}
+  }

I did this, but the test suite informs me that this contradicts the resolution 
of DR497: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497 I 
guess 253 supersedes 497; I'll update the test.


http://reviews.llvm.org/D16552



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


Re: [PATCH] D16552: Implement the likely resolution of core issue 253.

2016-02-18 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 48376.
thakis added a comment.

update test


http://reviews.llvm.org/D16552

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
  test/CXX/dcl.decl/dcl.init/p6.cpp
  test/CXX/drs/dr4xx.cpp
  test/SemaCXX/attr-selectany.cpp
  test/SemaCXX/constexpr-value-init.cpp
  test/SemaCXX/cxx0x-cursory-default-delete.cpp
  test/SemaCXX/illegal-member-initialization.cpp

Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1197,12 +1197,12 @@
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 
-namespace dr497 { // dr497: yes
+namespace dr497 { // dr497: no, superseded by dr253
   void before() {
 struct S {
   mutable int i;
 };
-const S cs; // expected-error {{default initialization}}
+const S cs;
 int S::*pm = &S::i;
 cs.*pm = 88; // expected-error {{not assignable}}
   }
Index: test/SemaCXX/illegal-member-initialization.cpp
===
--- test/SemaCXX/illegal-member-initialization.cpp
+++ test/SemaCXX/illegal-member-initialization.cpp
@@ -7,6 +7,7 @@
 };
 
 struct B {
+  int field;
 };
 
 struct X {
Index: test/SemaCXX/cxx0x-cursory-default-delete.cpp
===
--- test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -11,6 +11,7 @@
   non_const_copy& operator = (non_const_copy&) &;
   non_const_copy& operator = (non_const_copy&) &&;
   non_const_copy() = default; // expected-note {{not viable}}
+  int uninit_field;
 };
 non_const_copy::non_const_copy(non_const_copy&) = default; // expected-note {{not viable}}
 non_const_copy& non_const_copy::operator = (non_const_copy&) & = default; // expected-note {{not viable}}
@@ -30,6 +31,65 @@
   ncc = cncc; // expected-error {{no viable overloaded}}
 };
 
+struct no_fields { };
+struct all_init {
+  int a = 0;
+  int b = 0;
+};
+struct some_init {
+  int a = 0;
+  int b;
+  int c = 0;
+};
+struct some_init_mutable {
+  int a = 0;
+  mutable int b;
+  int c = 0;
+};
+struct some_init_def {
+  some_init_def() = default;
+  int a = 0;
+  int b;
+  int c = 0;
+};
+struct some_init_ctor {
+  some_init_ctor();
+  int a = 0;
+  int b;
+  int c = 0;
+};
+struct sub_some_init : public some_init_def { };
+struct sub_some_init_ctor : public some_init_def {
+  sub_some_init_ctor();
+};
+struct sub_some_init_ctor2 : public some_init_ctor {
+};
+struct some_init_container {
+  some_init_def sid;
+};
+struct some_init_container_ctor {
+  some_init_container_ctor();
+  some_init_def sid;
+};
+struct no_fields_container {
+  no_fields nf;
+};
+
+void constobjs() {
+  const no_fields nf; // ok
+  const all_init ai; // ok
+  const some_init si; // expected-error {{default initialization of an object of const type 'const some_init' without a user-provided default constructor}}
+  const some_init_mutable sim; // ok
+  const some_init_def sid; // expected-error {{default initialization of an object of const type 'const some_init_def' without a user-provided default constructor}}
+  const some_init_ctor sic; // ok
+  const sub_some_init ssi; // expected-error {{default initialization of an object of const type 'const sub_some_init' without a user-provided default constructor}}
+  const sub_some_init_ctor ssic; // ok
+  const sub_some_init_ctor2 ssic2; // ok
+  const some_init_container sicon; // expected-error {{default initialization of an object of const type 'const some_init_container' without a user-provided default constructor}}
+  const some_init_container_ctor siconc; // ok
+  const no_fields_container nfc; // ok
+}
+
 struct non_const_derived : non_const_copy {
   non_const_derived(const non_const_derived&) = default; // expected-error {{requires it to be non-const}}
   non_const_derived& operator =(non_const_derived&) = default;
Index: test/SemaCXX/constexpr-value-init.cpp
===
--- test/SemaCXX/constexpr-value-init.cpp
+++ test/SemaCXX/constexpr-value-init.cpp
@@ -14,7 +14,7 @@
   constexpr A a; // expected-error {{constant expression}} expected-note {{in call to 'A()'}}
 }
 
-constexpr B b1; // expected-error {{without a user-provided default constructor}}
+constexpr B b1; // ok
 constexpr B b2 = B(); // ok
 static_assert(b2.a.a == 1, "");
 static_assert(b2.a.b == 2, "");
Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -39,7 +39,9 @@
 // The D3D11 headers do something like this.  MSVC doesn't error on this at
 // all, even without the __declspec(selectany), in violati

r261247 - Make deprecation message for -fsanitize-coverage= with numeric argument friendlier.

2016-02-18 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Feb 18 13:32:54 2016
New Revision: 261247

URL: http://llvm.org/viewvc/llvm-project?rev=261247&view=rev
Log:
Make deprecation message for -fsanitize-coverage= with numeric argument 
friendlier.

http://reviews.llvm.org/D17397

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=261247&r1=261246&r2=261247&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Feb 18 13:32:54 2016
@@ -444,23 +444,31 @@ SanitizerArgs::SanitizerArgs(const ToolC
   !StringRef(Arg->getValue(0))
.getAsInteger(0, LegacySanitizeCoverage) &&
   LegacySanitizeCoverage >= 0 && LegacySanitizeCoverage <= 4) {
-D.Diag(diag::warn_drv_deprecated_arg)
-<< Arg->getAsString(Args) << "-fsanitize-coverage=[func,bb,edge]";
-// TODO: Add deprecation notice for this form.
 switch (LegacySanitizeCoverage) {
 case 0:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=";
   CoverageFeatures = 0;
   break;
 case 1:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=func";
   CoverageFeatures = CoverageFunc;
   break;
 case 2:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=bb";
   CoverageFeatures = CoverageBB;
   break;
 case 3:
+  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
+<< "-fsanitize-coverage=edge";
   CoverageFeatures = CoverageEdge;
   break;
 case 4:
+  D.Diag(diag::warn_drv_deprecated_arg)
+  << Arg->getAsString(Args)
+  << "-fsanitize-coverage=edge,indirect-calls";
   CoverageFeatures = CoverageEdge | CoverageIndirCall;
   break;
 }

Modified: cfe/trunk/test/Driver/fsanitize-coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-coverage.c?rev=261247&r1=261246&r2=261247&view=diff
==
--- cfe/trunk/test/Driver/fsanitize-coverage.c (original)
+++ cfe/trunk/test/Driver/fsanitize-coverage.c Thu Feb 18 13:32:54 2016
@@ -22,7 +22,7 @@
 // CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-indirect-calls
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=3 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-3
-// CHECK-SANITIZE-COVERAGE-3: warning: argument '-fsanitize-coverage=3' is 
deprecated, use '-fsanitize-coverage=[func,bb,edge]' instead
+// CHECK-SANITIZE-COVERAGE-3: warning: argument '-fsanitize-coverage=3' is 
deprecated, use '-fsanitize-coverage=edge' instead
 //
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=5 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-5
 // CHECK-SANITIZE-COVERAGE-5: error: unsupported argument '5' to option 
'fsanitize-coverage='


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


Re: [PATCH] D17397: Make deprecation message for -fsanitize-coverage= with numeric argument friendlier.

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

261247


http://reviews.llvm.org/D17397



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


Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-02-18 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3799-3806
@@ -3780,4 +3798,10 @@
   OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// \brief Emit the num_teams clause of an enclosed teams directive at the
+/// target region scope. If there is no teams directive associated with the
+/// target directive, or if there is no num_teams clause associated with the
+/// enclosed teams directive, return nullptr.
+static llvm::Value *
+emitNumTeamsClauseForTargetDirective(CodeGenFunction &CGF,

ABataev wrote:
> sfantao wrote:
> > ABataev wrote:
> > > I don't understand why global var is not captured in target region. If it 
> > > is not implemented yet, it must be implemented. If it is not captured, it 
> > > must be captured in Sema. We should not introduce some function/other 
> > > objects to find a workaround for 'not implemented' features.
> > Sorry, I was not clear in my comment. It is not that globals are not 
> > captured in target regions - they are, we already have Sema doing that. 
> > 
> > My point is that exactly because we capture globals in target regions the 
> > magic that `OMPCapturedExprDecl` introduces does not work for that specific 
> > case. So, if we have something like:
> > 
> > ```
> > int Gbl;
> > 
> > foo() {
> >   #pragma omp target
> >   #pragma omp teams num_teams(Gbl)
> >   {}
> > }
> > ```
> > when the DeclRefExpr for Gbl used in num_teams is emitted in the scope that 
> > encloses '#pragma omp target', it will crash because Gbl is not a local and 
> > is marked as refer to enclosing capture. 
> > 
> > If I got it right, a solution based on `OMPCapturedExprDecl` basically 
> > makes local declarations whose initializers are the expression we are 
> > interested in. In the cases that  `OMPCapturedExprDecl` is currently 
> > employed we don't have globals being captured and that is why it works fine.
> > 
> > It is likely I am missing something here. Let me know if you need me to 
> > provide more details.
> > 
> > Thanks!
> It should not crash, because if it is captured, we must use captured version 
> of this variable, passed in arguments to outlined function
I am afraid I may not be understanding what you want me to do. Going back to my 
example:

```
int Gbl;

foo() {
  // a) I need to emit num_teams(Gbl) here. DeclRefExpr(Gbl) emission won't 
work because it is marked "refer to enclosing capture". 
  #pragma omp target
  // b) If I emit it here, that's fine because I already have the arguments of 
the outlined function, but that is not what I need.
  #pragma omp teams num_teams(Gbl)
  {}
}
```
Can you please elaborate on how `OMPCapturedExprDecl` would help me implement 
a). Sorry for the trouble.

Thanks!


http://reviews.llvm.org/D17019



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


r261248 - [analyzer] Include comment mistakenly left out of r261243. NFC.

2016-02-18 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Feb 18 13:37:39 2016
New Revision: 261248

URL: http://llvm.org/viewvc/llvm-project?rev=261248&view=rev
Log:
[analyzer] Include comment mistakenly left out of r261243. NFC.

It explains why we can't just synthesize bodies of setters in BodyFarm.

Modified:
cfe/trunk/lib/Analysis/BodyFarm.cpp

Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=261248&r1=261247&r2=261248&view=diff
==
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Thu Feb 18 13:37:39 2016
@@ -498,6 +498,14 @@ Stmt *BodyFarm::getBody(const ObjCMethod
 return nullptr;
 
   // For now, we only synthesize getters.
+  // Synthesizing setters would cause false negatives in the
+  // RetainCountChecker because the method body would bind the parameter
+  // to an instance variable, causing it to escape. This would prevent
+  // warning in the following common scenario:
+  //
+  //  id foo = [[NSObject alloc] init];
+  //  self.foo = foo; // We should warn that foo leaks here.
+  //
   if (D->param_size() != 0)
 return nullptr;
 


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


Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-18 Thread Carlo Bertolli via cfe-commits
carlo.bertolli added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:187-208
@@ -185,30 +186,24 @@
+
+public:
   /// \brief Values for bit flags used in the ident_t to describe the fields.
   /// All enumeric elements are named and described in accordance with the code
   /// from http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp.h
   enum OpenMPLocationFlags {
 /// \brief Use trampoline for internal microtask.
 OMP_IDENT_IMD = 0x01,
 /// \brief Use c-style ident structure.
 OMP_IDENT_KMPC = 0x02,
 /// \brief Atomic reduction option for kmpc_reduce.
 OMP_ATOMIC_REDUCE = 0x10,
 /// \brief Explicit 'barrier' directive.
 OMP_IDENT_BARRIER_EXPL = 0x20,
 /// \brief Implicit barrier in code.
 OMP_IDENT_BARRIER_IMPL = 0x40,
 /// \brief Implicit barrier in 'for' directive.
 OMP_IDENT_BARRIER_IMPL_FOR = 0x40,
 /// \brief Implicit barrier in 'sections' directive.
 OMP_IDENT_BARRIER_IMPL_SECTIONS = 0xC0,
 /// \brief Implicit barrier in 'single' directive.
 OMP_IDENT_BARRIER_IMPL_SINGLE = 0x140
   };
 

ABataev wrote:
> No, do not make it public. It must be private forever. Moreover, It would be 
> good if could hide it at all in .cpp file. I will look at it.
Waiting for you.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:553-566
@@ -564,2 +552,16 @@
 
+  /// \brief Emits object of ident_t type with info for source location.
+  /// \param Flags Flags for OpenMP location.
+  ///
+  llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
+  OpenMPLocationFlags Flags = OMP_IDENT_KMPC);
+
+  /// \brief Gets thread id value for the current thread.
+  ///
+  llvm::Value *getThreadID(CodeGenFunction &CGF, SourceLocation Loc);
+
+  /// \brief Returns __kmpc_for_static_init_* runtime function for the 
specified
+  /// size \a IVSize and sign \a IVSigned.
+  llvm::Constant *createForStaticInitFunction(unsigned IVSize, bool IVSigned);
+
   /// \brief Emits outlined function for the specified OpenMP parallel 
directive

ABataev wrote:
> Keep them private, please
Waiting for you - If the basic emission routine for kmpc_for_static_init needs 
to be a static function in CGOpenMPRuntime.cpp, then this must be accessible 
somehow.


Repository:
  rL LLVM

http://reviews.llvm.org/D17170



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


Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-18 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 48379.
carlo.bertolli marked 4 inline comments as done.
carlo.bertolli added a comment.

Partially address comments to replace schedule type with schedule num in 
interface of static function generating call to kmpc_for_static_init. Still 
waiting for updates on private members of CGOpenMPRuntime.cpp


Repository:
  rL LLVM

http://reviews.llvm.org/D17170

Files:
  include/clang/AST/StmtOpenMP.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/distribute_codegen.cpp

Index: test/OpenMP/distribute_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/distribute_codegen.cpp
@@ -0,0 +1,239 @@
+// 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 --check-prefix CHECK --check-prefix CHECK-64
+// 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 --check-prefix CHECK --check-prefix CHECK-64  --check-prefix HCHECK
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32  --check-prefix HCHECK
+// 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 --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
+
+// Test target codegen - host bc file has to be created first. (no significant differences with host version of target region)
+// 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
+// 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
+// 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
+// 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
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
+void without_schedule_clause(float *a, float *b, float *c, float *d) {
+  #pragma omp target
+  #pragma omp teams
+  #pragma omp distribute
+  for (int i = 33; i < 3200; i += 7) {
+a[i] = b[i] * c[i] * d[i];
+  }
+}
+
+// CHECK: define {{.*}}void @.omp_outlined.(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
+// CHECK:  [[TID_ADDR:%.+]] = alloca i32*
+// CHECK:  [[IV:%.+iv]] = alloca i32
+// CHECK:  [[LB:%.+lb]] = alloca i32
+// CHECK:  [[UB:%.+ub]] = alloca i32
+// CHECK:  [[ST:%.+stride]] = alloca i32
+// CHECK:  [[LAST:%.+last]] = alloca

[PATCH] D17405: Use Backend_EmitMCNull for null codegen unit tests.

2016-02-18 Thread David L. Jones via cfe-commits
dlj created this revision.
dlj added a subscriber: cfe-commits.

Using Backend_EmitLL attemps to create a file with an empty filename.
This is problematic in certain environments: an empty filename may be
illegal, or the default output path may not be writable (in the case
where an empty filename would otherwise have some non-failing
semantics). This patch switches to use Backend_EmitMCNull, which
allows CodeGen to run, but does not attempt to create or write an
output file.

http://reviews.llvm.org/D17405

Files:
  unittests/Frontend/CodeGenActionTest.cpp

Index: unittests/Frontend/CodeGenActionTest.cpp
===
--- unittests/Frontend/CodeGenActionTest.cpp
+++ unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {


Index: unittests/Frontend/CodeGenActionTest.cpp
===
--- unittests/Frontend/CodeGenActionTest.cpp
+++ unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261251 - Make test less prone to attribute changes

2016-02-18 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Thu Feb 18 14:02:03 2016
New Revision: 261251

URL: http://llvm.org/viewvc/llvm-project?rev=261251&view=rev
Log:
Make test less prone to attribute changes

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

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=261251&r1=261250&r2=261251&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Thu Feb 18 14:02:03 2016
@@ -18,7 +18,7 @@ void *test_InterlockedExchangePointer(vo
   return _InterlockedExchangePointer(Target, Value);
 }
 
-// CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** %Target, i8* 
%Value){{.*}}{
+// CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** {{[a-z_ 
]*}}%Target, i8* %Value){{.*}}{
 // CHECK:   %[[TARGET:[0-9]+]] = bitcast i8** %Target to [[iPTR:i[0-9]+]]*
 // CHECK:   %[[VALUE:[0-9]+]] = ptrtoint i8* %Value to [[iPTR]]
 // CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg [[iPTR]]* %[[TARGET]], 
[[iPTR]] %[[VALUE]] seq_cst
@@ -31,7 +31,7 @@ void *test_InterlockedCompareExchangePoi
   return _InterlockedCompareExchangePointer(Destination, Exchange, Comparand);
 }
 
-// CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** 
%Destination, i8* %Exchange, i8* %Comparand){{.*}}{
+// CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** 
nocapture %Destination, i8* %Exchange, i8* %Comparand){{.*}}{
 // CHECK:   %[[DEST:[0-9]+]] = bitcast i8** %Destination to [[iPTR]]*
 // CHECK:   %[[EXCHANGE:[0-9]+]] = ptrtoint i8* %Exchange to [[iPTR]]
 // CHECK:   %[[COMPARAND:[0-9]+]] = ptrtoint i8* %Comparand to [[iPTR]]
@@ -45,7 +45,7 @@ long test_InterlockedExchange(long *Targ
   return _InterlockedExchange(Target, Value);
 }
 
-// CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* %Target, i32 
%Value){{.*}}{
+// CHECK: define{{.*}}i32 @test_InterlockedExchange(i32* {{[a-z_ ]*}}%Target, 
i32 %Value){{.*}}{
 // CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %Target, i32 %Value 
seq_cst
 // CHECK:   ret i32 %[[EXCHANGE:[0-9]+]]
 // CHECK: }


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


Re: [PATCH] D17405: Use Backend_EmitMCNull for null codegen unit tests.

2016-02-18 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith accepted this revision.
rsmith added a reviewer: rsmith.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D17405



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


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 48384.
ahatanak added a comment.

Address Manman's review comments. Handle elements with "LocalAlignment == 8" 
similarly to those with "LocalAlignment == 4".


http://reviews.llvm.org/D16843

Files:
  lib/Sema/TypeLocBuilder.cpp
  test/SemaObjCXX/typeloc-data-alignment.mm

Index: test/SemaObjCXX/typeloc-data-alignment.mm
===
--- /dev/null
+++ test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: lib/Sema/TypeLocBuilder.cpp
===
--- lib/Sema/TypeLocBuilder.cpp
+++ lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,39 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
-  Index -= 4;
+if (NumBytesAtAlign8 == 0) {
+  // We have not seen any 8-byte aligned element yet. We insert a padding
+  // only if the new Index is not 8-byte-aligned.
+  if ((Index - LocalSize) % 8 != 0) {
+   memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+   Index -= 4;
+  }
+} else {
+  unsigned Padding = NumBytesAtAlign4 % 8;
+  if (Padding == 0) {
+   if (LocalSize % 8 == 0) {
+ // Everything is set: there's no padding and we don't need to add
+ // any.
+   } else {
+ assert(LocalSize % 8 == 4);
+ // No existing padding; add in 4 bytes padding
+ memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+ Index -= 4;
+   }
+  } else {
+   assert(Padding == 4);
+   if (LocalSize % 8 == 0) {
+ // Everything is set: there's 4 bytes padding and we don't need
+ // to add any.
+   } else {
+ assert(LocalSize % 8 == 4);
+ // There are 4 bytes padding, but we don't need any; remove it.
+ memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
+ Index += 4;
+   }
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;


Index: test/SemaObjCXX/typeloc-data-alignment.mm
===
--- /dev/null
+++ test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: lib/Sema/TypeLocBuilder.cpp
===
--- lib/Sema/TypeLocBuilder.cpp
+++ lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,39 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
-  Index -= 4;
+if (NumBytesAtAlign8 == 0) {
+  // We have not seen any 8-byte aligned element yet. We insert a padding
+  // only if the new Index is not 8-byte-aligned.
+  if ((Index - LocalSize) % 8 != 0) {
+	memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+	Index -= 4;
+  }
+} else {
+  unsigned Padding = NumBytesAtAlign4 % 8;
+  if (Padding == 0) {
+	if (LocalSize % 8 == 0) {
+	  // Everything is set: there's no padding and we don't need to add
+	  // any.
+	} else {
+	  assert(LocalSize % 8 == 4);
+	  // No existing padding; add in 4 bytes padding
+	  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+	  Index -= 4;
+	}
+  } else {
+	assert(Padding == 4);
+	if (LocalSize % 8 == 0) {
+	  // Everything is set: there's 4 bytes padding and we don't need
+	  // to add any.
+	} else {
+	  assert(LocalSize % 8 == 4);
+	  // There are 4 bytes padding, but we don't need any; remove it.
+	  memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
+	  Index += 4;
+	}
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17405: Use Backend_EmitMCNull for null codegen unit tests.

2016-02-18 Thread David L. Jones via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261252: Use Backend_EmitMCNull for null codegen unit tests. 
(authored by dlj).

Changed prior to commit:
  http://reviews.llvm.org/D17405?vs=48380&id=48386#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17405

Files:
  cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp

Index: cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
===
--- cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
+++ cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {


Index: cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
===
--- cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
+++ cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
@@ -26,7 +26,7 @@
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261252 - Use Backend_EmitMCNull for null codegen unit tests.

2016-02-18 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Feb 18 14:27:16 2016
New Revision: 261252

URL: http://llvm.org/viewvc/llvm-project?rev=261252&view=rev
Log:
Use Backend_EmitMCNull for null codegen unit tests.

Using Backend_EmitLL attemps to create a file with an empty filename.
This is problematic in certain environments: an empty filename may be
illegal, or the default output path may not be writable (in the case
where an empty filename would otherwise have some non-failing
semantics). This patch switches to use Backend_EmitMCNull, which
allows CodeGen to run, but does not attempt to create or write an
output file.

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

Modified:
cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp

Modified: cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp?rev=261252&r1=261251&r2=261252&view=diff
==
--- cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp (original)
+++ cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp Thu Feb 18 14:27:16 2016
@@ -26,7 +26,7 @@ namespace {
 class NullCodeGenAction : public CodeGenAction {
 public:
   NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
-: CodeGenAction(Backend_EmitLL, _VMContext) {}
+: CodeGenAction(Backend_EmitMCNull, _VMContext) {}
 
   // The action does not call methods of ATContext.
   void ExecuteAction() override {


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


r261253 - Missed a spot in r261251, also ignore attributes on all pointer parameters

2016-02-18 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Thu Feb 18 14:30:40 2016
New Revision: 261253

URL: http://llvm.org/viewvc/llvm-project?rev=261253&view=rev
Log:
Missed a spot in r261251, also ignore attributes on all pointer parameters

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

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=261253&r1=261252&r2=261253&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Thu Feb 18 14:30:40 2016
@@ -18,7 +18,7 @@ void *test_InterlockedExchangePointer(vo
   return _InterlockedExchangePointer(Target, Value);
 }
 
-// CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** {{[a-z_ 
]*}}%Target, i8* %Value){{.*}}{
+// CHECK: define{{.*}}i8* @test_InterlockedExchangePointer(i8** {{[a-z_ 
]*}}%Target, i8* {{[a-z_ ]*}}%Value){{.*}}{
 // CHECK:   %[[TARGET:[0-9]+]] = bitcast i8** %Target to [[iPTR:i[0-9]+]]*
 // CHECK:   %[[VALUE:[0-9]+]] = ptrtoint i8* %Value to [[iPTR]]
 // CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg [[iPTR]]* %[[TARGET]], 
[[iPTR]] %[[VALUE]] seq_cst
@@ -31,7 +31,7 @@ void *test_InterlockedCompareExchangePoi
   return _InterlockedCompareExchangePointer(Destination, Exchange, Comparand);
 }
 
-// CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** 
nocapture %Destination, i8* %Exchange, i8* %Comparand){{.*}}{
+// CHECK: define{{.*}}i8* @test_InterlockedCompareExchangePointer(i8** {{[a-z_ 
]*}}%Destination, i8* {{[a-z_ ]*}}%Exchange, i8* {{[a-z_ ]*}}%Comparand){{.*}}{
 // CHECK:   %[[DEST:[0-9]+]] = bitcast i8** %Destination to [[iPTR]]*
 // CHECK:   %[[EXCHANGE:[0-9]+]] = ptrtoint i8* %Exchange to [[iPTR]]
 // CHECK:   %[[COMPARAND:[0-9]+]] = ptrtoint i8* %Comparand to [[iPTR]]


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


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 48387.
ahatanak added a comment.

Fix indentation.


http://reviews.llvm.org/D16843

Files:
  lib/Sema/TypeLocBuilder.cpp
  test/SemaObjCXX/typeloc-data-alignment.mm

Index: test/SemaObjCXX/typeloc-data-alignment.mm
===
--- /dev/null
+++ test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: lib/Sema/TypeLocBuilder.cpp
===
--- lib/Sema/TypeLocBuilder.cpp
+++ lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,39 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
-  Index -= 4;
+if (NumBytesAtAlign8 == 0) {
+  // We have not seen any 8-byte aligned element yet. We insert a padding
+  // only if the new Index is not 8-byte-aligned.
+  if ((Index - LocalSize) % 8 != 0) {
+memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+Index -= 4;
+  }
+} else {
+  unsigned Padding = NumBytesAtAlign4 % 8;
+  if (Padding == 0) {
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's no padding and we don't need to add
+  // any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // No existing padding; add in 4 bytes padding
+  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+  Index -= 4;
+}
+  } else {
+assert(Padding == 4);
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's 4 bytes padding and we don't need
+  // to add any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // There are 4 bytes padding, but we don't need any; remove it.
+  memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
+  Index += 4;
+}
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;


Index: test/SemaObjCXX/typeloc-data-alignment.mm
===
--- /dev/null
+++ test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: lib/Sema/TypeLocBuilder.cpp
===
--- lib/Sema/TypeLocBuilder.cpp
+++ lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,39 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
-  Index -= 4;
+if (NumBytesAtAlign8 == 0) {
+  // We have not seen any 8-byte aligned element yet. We insert a padding
+  // only if the new Index is not 8-byte-aligned.
+  if ((Index - LocalSize) % 8 != 0) {
+memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+Index -= 4;
+  }
+} else {
+  unsigned Padding = NumBytesAtAlign4 % 8;
+  if (Padding == 0) {
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's no padding and we don't need to add
+  // any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // No existing padding; add in 4 bytes padding
+  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+  Index -= 4;
+}
+  } else {
+assert(Padding == 4);
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's 4 bytes padding and we don't need
+  // to add any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // There are 4 bytes padding, but we don't need any; remove it.
+  memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
+  Index += 4;
+}
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks Akira,

LGTM.

Manman


http://reviews.llvm.org/D16843



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


[PATCH] D17407: [Sema] PR25755 Fix crash when initializing out-of-order struct references

2016-02-18 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: rsmith.
hintonda added a subscriber: cfe-commits.

Remove assert that fired whenever initialization lists had
errors, and pass VerifyOnly=false to PerformEmptyInit so we'll get diagnostics.

http://reviews.llvm.org/D17407

Files:
  lib/Sema/SemaInit.cpp
  test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
  test/SemaCXX/cxx0x-initializer-aggregates.cpp
  test/SemaCXX/cxx0x-initializer-constructor.cpp
  test/SemaCXX/dcl_init_aggr.cpp
  test/SemaCXX/pr23514-crash-on-invalid.cpp

Index: test/SemaCXX/pr23514-crash-on-invalid.cpp
===
--- /dev/null
+++ test/SemaCXX/pr23514-crash-on-invalid.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// Don't crash (PR13394).
+
+struct Test {
+  int& a;
+  int& b; // expected-note {{in implicit initialization of field 'b' with omitted initializer}}
+};
+
+int d = 0;
+auto a = Test {
+  .b = d,
+  .a = d,
+}; // expected-error {{reference to type 'int' requires an initializer}}
Index: test/SemaCXX/dcl_init_aggr.cpp
===
--- test/SemaCXX/dcl_init_aggr.cpp
+++ test/SemaCXX/dcl_init_aggr.cpp
@@ -40,21 +40,24 @@
 struct TooFew { int a; char* b; int c; }; 
 TooFew too_few = { 1, "asdf" }; // expected-warning{{conversion from string literal to 'char *' is deprecated}}
 
-struct NoDefaultConstructor { // expected-note 3 {{candidate constructor (the implicit copy constructor)}} \
+struct NoDefaultConstructor { // expected-note 6 {{candidate constructor (the implicit copy constructor)}} \
   // expected-note{{declared here}}
-  NoDefaultConstructor(int); // expected-note 3 {{candidate constructor}}
+  NoDefaultConstructor(int); // expected-note 6 {{candidate constructor}}
 };
-struct TooFewError { // expected-error{{implicit default constructor for}}
+struct TooFewError { // expected-error{{implicit default constructor for}} \
+ // expected-note {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
   int a;
-  NoDefaultConstructor nodef; // expected-note{{member is declared here}} expected-note 2{{in implicit initialization of field 'nodef'}}
+  NoDefaultConstructor nodef; // expected-note{{member is declared here}} expected-note 4{{in implicit initialization of field 'nodef'}}
 };
 TooFewError too_few_okay = { 1, 1 };
-TooFewError too_few_error = { 1 }; // expected-error{{no matching constructor}}
+TooFewError too_few_error = { 1 }; // expected-error 2{{no matching constructor}}
 
-TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}}
-TooFewError too_few_error2[2] = { 1 }; // expected-error{{no matching constructor}}
+TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}} \
+ // expected-error {{no matching constructor}} \
+ // expected-note {{in implicit initialization of array element 1 with omitted initializer}}
+TooFewError too_few_error2[2] = { 1 }; // expected-error 2{{no matching constructor}}
 
-NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}} expected-note {{implicit initialization of array element 0}}
+NoDefaultConstructor too_few_error3[3] = { }; // expected-error 2{{no matching constructor}} expected-note 2 {{implicit initialization of array element 0}}
 
 // C++ [dcl.init.aggr]p8
 struct Empty { };
@@ -76,11 +79,13 @@
 // C++ [dcl.init.aggr]p9
 struct HasReference {
   int i;
-  int &j; // expected-note{{uninitialized reference member is here}}
+  int &j; // expected-note{{uninitialized reference member is here}} \
+  // expected-note {{in implicit initialization of field 'j' with omitted initializer}}
 };
 int global_int;
 HasReference r1 = { 1, global_int };
-HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}}
+HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}} \
+  // expected-error {{reference to type 'int' requires an initializer}}
 
 // C++ [dcl.init.aggr]p10
 // Note: the behavior here is identical to C
Index: test/SemaCXX/cxx0x-initializer-constructor.cpp
===
--- test/SemaCXX/cxx0x-initializer-constructor.cpp
+++ test/SemaCXX/cxx0x-initializer-constructor.cpp
@@ -382,27 +382,31 @@
 
 namespace PR11410 {
   struct A {
-A() = delete; // expected-note 2{{deleted here}}
+A() = delete; // expected-note 4{{'A' has been explicitly marked deleted here}}
 A(int);
   };
 
   A a[3] = {
 {1}, {2}
-  }; // expected-error {{call to deleted constructor}} \
-expected-note {{in implicit initializa

Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-02-18 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3901-3932
@@ +3900,34 @@
+// Reference types are ignored for mapping purposes.
+if (auto *RefTy = ExprTy->getAs())
+  ExprTy = RefTy->getPointeeType().getCanonicalType();
+
+// Given that an array section is considered a built-in type, we need to
+// do the calculation based on the length of the section instead of relying
+// on CGF.getTypeSize(E->getType()).
+if (const auto *OAE = dyn_cast(E)) {
+  auto BaseTy =
+  OAE->getBase()->IgnoreParenImpCasts()->getType().getCanonicalType();
+  // Reference types are ignored for mapping purposes.
+  if (auto *RefTy = BaseTy->getAs())
+BaseTy = RefTy->getPointeeType().getCanonicalType();
+
+  // If there is no length associated with the expression, that means we
+  // are using the whole length of the base.
+  if (!OAE->getLength())
+return CGF.getTypeSize(BaseTy);
+
+  llvm::Value *ElemSize;
+  if (auto *PTy = BaseTy->getAs()) {
+ElemSize = CGF.getTypeSize(PTy->getPointeeType().getCanonicalType());
+  } else {
+auto *ATy = cast(BaseTy.getTypePtr());
+assert(ATy && "Expecting array type if not a pointer type.");
+ElemSize = CGF.getTypeSize(ATy->getElementType().getCanonicalType());
+  }
+
+  auto *LengthVal = CGF.EmitScalarExpr(OAE->getLength());
+  LengthVal =
+  CGF.Builder.CreateIntCast(LengthVal, CGF.SizeTy, /*isSigned=*/false);
+  return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
+}
+return CGF.getTypeSize(ExprTy);

ABataev wrote:
> 'marr[:][:][:2]' produces contiguous storage, no? Is this allowed? And if it 
> is allowed, how it will be handled? Besides, if 'marr' is a pointer, even 
> 'marr[:2][:3][:4]' may result in contiguous space.
> 'marr[:][:][:2]' produces contiguous storage, no? Is this allowed? And if it 
> is allowed, how it will be handled?
That is not contiguous so it is not allowed. `marr[:2][:][:]` is contiguous 
storage but can be expressed as `marr[:2]` only. Do you think I should create a 
patch to allow the latter case in Sema? Should it be part of this patch?

> Besides, if 'marr' is a pointer, even 'marr[:2][:3][:4]' may result in 
> contiguous space.
This is illegal. This requires multiple memory allocations that are not 
contiguous on the host.


http://reviews.llvm.org/D16749



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


r261260 - [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Feb 18 15:05:09 2016
New Revision: 261260

URL: http://llvm.org/viewvc/llvm-project?rev=261260&view=rev
Log:
[Sema] Fix bug in TypeLocBuilder::pushImpl

The code in TypeLocBuilder::pushImpl wasn't correctly handling the case
where an element that has an 8-byte alignment was being pushed.

I plan to follow up with a patch to remove redundancies and simplify the
function.

rdar://problem/23838912

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

Added:
cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
Modified:
cfe/trunk/lib/Sema/TypeLocBuilder.cpp

Modified: cfe/trunk/lib/Sema/TypeLocBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TypeLocBuilder.cpp?rev=261260&r1=261259&r2=261260&view=diff
==
--- cfe/trunk/lib/Sema/TypeLocBuilder.cpp (original)
+++ cfe/trunk/lib/Sema/TypeLocBuilder.cpp Thu Feb 18 15:05:09 2016
@@ -115,11 +115,39 @@ TypeLoc TypeLocBuilder::pushImpl(QualTyp
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
-  Index -= 4;
+if (NumBytesAtAlign8 == 0) {
+  // We have not seen any 8-byte aligned element yet. We insert a padding
+  // only if the new Index is not 8-byte-aligned.
+  if ((Index - LocalSize) % 8 != 0) {
+memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+Index -= 4;
+  }
+} else {
+  unsigned Padding = NumBytesAtAlign4 % 8;
+  if (Padding == 0) {
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's no padding and we don't need to add
+  // any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // No existing padding; add in 4 bytes padding
+  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+  Index -= 4;
+}
+  } else {
+assert(Padding == 4);
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's 4 bytes padding and we don't need
+  // to add any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // There are 4 bytes padding, but we don't need any; remove it.
+  memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
+  Index += 4;
+}
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;

Added: cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm?rev=261260&view=auto
==
--- cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm (added)
+++ cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm Thu Feb 18 15:05:09 2016
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}


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


Re: [PATCH] D16843: [Sema] Fix bug in TypeLocBuilder::pushImpl

2016-02-18 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261260: [Sema] Fix bug in TypeLocBuilder::pushImpl (authored 
by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D16843?vs=48387&id=48392#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16843

Files:
  cfe/trunk/lib/Sema/TypeLocBuilder.cpp
  cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm

Index: cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
===
--- cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
+++ cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: cfe/trunk/lib/Sema/TypeLocBuilder.cpp
===
--- cfe/trunk/lib/Sema/TypeLocBuilder.cpp
+++ cfe/trunk/lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,39 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
-  Index -= 4;
+if (NumBytesAtAlign8 == 0) {
+  // We have not seen any 8-byte aligned element yet. We insert a padding
+  // only if the new Index is not 8-byte-aligned.
+  if ((Index - LocalSize) % 8 != 0) {
+memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+Index -= 4;
+  }
+} else {
+  unsigned Padding = NumBytesAtAlign4 % 8;
+  if (Padding == 0) {
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's no padding and we don't need to add
+  // any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // No existing padding; add in 4 bytes padding
+  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+  Index -= 4;
+}
+  } else {
+assert(Padding == 4);
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's 4 bytes padding and we don't need
+  // to add any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // There are 4 bytes padding, but we don't need any; remove it.
+  memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
+  Index += 4;
+}
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;


Index: cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
===
--- cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
+++ cfe/trunk/test/SemaObjCXX/typeloc-data-alignment.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Make sure this doesn't crash.
+
+@protocol P
+@end
+template 
+id foo(T) {
+  int i;
+  foo(i);
+}
Index: cfe/trunk/lib/Sema/TypeLocBuilder.cpp
===
--- cfe/trunk/lib/Sema/TypeLocBuilder.cpp
+++ cfe/trunk/lib/Sema/TypeLocBuilder.cpp
@@ -115,11 +115,39 @@
   NumBytesAtAlign4 += LocalSize;
 }
   } else if (LocalAlignment == 8) {
-if (!NumBytesAtAlign8 && NumBytesAtAlign4 % 8 != 0) {
-  // No existing padding and misaligned members; add in 4 bytes padding
-  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
-  Index -= 4;
+if (NumBytesAtAlign8 == 0) {
+  // We have not seen any 8-byte aligned element yet. We insert a padding
+  // only if the new Index is not 8-byte-aligned.
+  if ((Index - LocalSize) % 8 != 0) {
+memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+Index -= 4;
+  }
+} else {
+  unsigned Padding = NumBytesAtAlign4 % 8;
+  if (Padding == 0) {
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's no padding and we don't need to add
+  // any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // No existing padding; add in 4 bytes padding
+  memmove(&Buffer[Index - 4], &Buffer[Index], NumBytesAtAlign4);
+  Index -= 4;
+}
+  } else {
+assert(Padding == 4);
+if (LocalSize % 8 == 0) {
+  // Everything is set: there's 4 bytes padding and we don't need
+  // to add any.
+} else {
+  assert(LocalSize % 8 == 4);
+  // There are 4 bytes padding, but we don't need any; remove it.
+  memmove(&Buffer[Index + 4], &Buffer[Index], NumBytesAtAlign4);
+  Index += 4;
+}
+  }
 }
+
 // Forget about any padding.
 NumBytesAtAlign4 = 0;
 NumBytesAtAlign8 += LocalSize;
___
cfe-commits mailing list
cfe-comm

[PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install

2016-02-18 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: mclow.lists, EricWF, danalbert, jroelofs.
bcraig added a subscriber: cfe-commits.

Prior to this patch, setting LIBCXXABI_LIBDIR_SUFFIX would confuse the 
check-libcxxabi target.  libc++abi.* would get output to lib instead of 
lib${LIBCXXABI_LIBDIR_SUFFIX}, but the tests would look in the suffixed 
directory.

Now, we match what libcxx does, and set the CMAKE_*_OUTPUT_DIRECTORY to the 
LIBRARY_DIR.  This is also being done in the "standalone" branch, but now it is 
being performed in the in-tree branch as well.


http://reviews.llvm.org/D17410

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -181,6 +181,9 @@
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+
 # By default, for non-standalone builds, libcxx and libcxxabi share a library
 # directory.
 if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -181,6 +181,9 @@
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+
 # By default, for non-standalone builds, libcxx and libcxxabi share a library
 # directory.
 if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install

2016-02-18 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 48396.
bcraig added a comment.

Prior version doesn't apply to master.  The context was dirty from some 
unsubmitted patches.


http://reviews.llvm.org/D17410

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -182,6 +182,9 @@
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+
 
#===
 # Setup Compiler Flags
 
#===


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -182,6 +182,9 @@
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+
 #===
 # Setup Compiler Flags
 #===
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17104: [VFS] Drop path traversal assertion

2016-02-18 Thread Bruno Cardoso Lopes via cfe-commits
bruno updated this revision to Diff 48397.
bruno added a comment.

Updated the patch, with the following changes:

  Handle ".", ".." and "./" with trailing slashes while collecting files
  to be dumped into the vfs overlay directory.
  
  Include the support for symlinks into components. Given the path:
  
  /install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"
  component is a symlink, it's not safe to use `path::remove_dots` here,
  and `realpath` is used to get the right answer. Since `realpath`
  is expensive, we only do it at collecting time (which only happens
  during the crash reproducer) and cache the base directory for fast lookups.
  
  Overall, this patch makes the input to the VFS YAML file to be canonicalized
  to never contain traversal components.


http://reviews.llvm.org/D17104

Files:
  lib/Basic/VirtualFileSystem.cpp
  lib/Frontend/ModuleDependencyCollector.cpp
  test/Modules/crash-vfs-path-symlink-component.m
  test/Modules/crash-vfs-path-traversal.m

Index: test/Modules/crash-vfs-path-traversal.m
===
--- /dev/null
+++ test/Modules/crash-vfs-path-traversal.m
@@ -0,0 +1,58 @@
+// REQUIRES: crash-recovery, shell
+
+// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
+// XFAIL: mingw32
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/i %t/m %t
+
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: %clang -fsyntax-only %s -I %S/Inputs/System -isysroot %/t/i/\
+// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
+
+// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
+// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
+// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
+// RUN: find %t/crash-vfs-*.cache/vfs | \
+// RUN:   grep "Inputs/System/usr/include/stdio.h" | count 1
+
+#include "usr/././//include/../include/./././../include/stdio.h"
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+
+// CHECKSRC: @import cstd.stdio;
+
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: "-fsyntax-only"
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-isysroot" "{{[^"]*}}/i/"
+// CHECKSH-NOT: "-fmodules-cache-path="
+// CHECKSH: "crash-vfs-{{[^ ]*}}.m"
+// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
+
+// CHECKYAML: 'type': 'directory'
+// CHECKYAML: 'name': "{{[^ ]*}}/Inputs/System/usr/include",
+// CHECKYAML-NEXT: 'contents': [
+// CHECKYAML-NEXT:   {
+// CHECKYAML-NEXT: 'type': 'file',
+// CHECKYAML-NEXT: 'name': "module.map",
+// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}/Inputs/System/usr/include/module.map"
+// CHECKYAML-NEXT:   },
+
+// Replace the paths in the YAML files with relative ".." traversals
+// and fed into clang to test whether we're correctly representing them
+// in the VFS overlay.
+
+// RUN: sed -e "s@usr/include@usr/include/../include@g" \
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml
+// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
+// RUN: %clang -E %s -I %S/Inputs/System -isysroot %/t/i/ \
+// RUN: -ivfsoverlay %t/vfs.yaml -fmodules \
+// RUN: -fmodules-cache-path=%t/m/ 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
+
+// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/usr/include/stdio.h"
Index: test/Modules/crash-vfs-path-symlink-component.m
===
--- /dev/null
+++ test/Modules/crash-vfs-path-symlink-component.m
@@ -0,0 +1,72 @@
+// REQUIRES: crash-recovery, shell
+
+// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
+// XFAIL: mingw32
+
+// Test that clang is capable of collecting the right header files in the
+// crash reproducer if there's a symbolic link component in the path.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/i %t/m %t %t/sysroot
+// RUN: cp -a %S/Inputs/System/usr %t/i/
+// RUN: ln -s include/tcl-private %t/i/usr/x
+
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \
+// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
+
+// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
+// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
+// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
+// RUN: find %t/crash-vfs-*.cache/vfs | \
+// RUN:   grep "usr/include/stdio.h" | count 1
+
+#include "usr/x/../stdio.h"
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
+// CHECK-NEXT: note: diagnostic

Re: [PATCH] D17360: [cfi] Fix handling of sanitize trap/recover flags in the cross-DSO CFI mode.

2016-02-18 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

This lets us support the following case:
module A checks vcalls and casts, with diagnostics
module B checks vcalls but not casts (but it still has bitsets for vtables), 
with diagnostics
then a cast check from module A with a target in module B should print 
diagnostics instead of trapping

It's definitely not critical functionality, but could be nice to have, 
especially as it does not cost us anything.

And yes, CodeGenModule::NeedAllVtablesBitSet needs to be fixed for this work.

WDYT?


Repository:
  rL LLVM

http://reviews.llvm.org/D17360



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


[PATCH] D17416: [libcxx] Reorganize locale extension fallbacks

2016-02-18 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: jroelofs, danalbert, mclow.lists.
bcraig added a subscriber: cfe-commits.
Herald added subscribers: srhines, danalbert, tberghammer, jfb.

This is one part of many of a locale refactor. See 
http://reviews.llvm.org/D17146 for an idea of where this is going.

The various _l locale extension functions originate from very different places. 
 Some come from POSIX, some are BSD extensions, and some are shared BSD and 
GLIBC extensions.  This patch tries to group the local extension 
reimplementations by source.  This should make it easier to make libcxx work 
with POSIX compliant C libraries that lack these extensions.

The fallback locale functions are also useful on their own for other 
lightweight platforms. Putting these fallback implementations in 
support/xlocale should enable code sharing.

I have no access to a newlib system or an android system to build and test 
with.  I _do_ have access to a system without any of the _l locale extensions 
though, and I was able to ensure that the new __posix_l_fallback.h and 
__strtonum_fallback.h didn't have any massive problems.


http://reviews.llvm.org/D17416

Files:
  include/support/android/locale_bionic.h
  include/support/newlib/xlocale.h
  include/support/xlocale/__posix_l_fallback.h
  include/support/xlocale/__strtonum_fallback.h
  include/support/xlocale/xlocale.h

Index: include/support/xlocale/xlocale.h
===
--- include/support/xlocale/xlocale.h
+++ /dev/null
@@ -1,194 +0,0 @@
-// -*- C++ -*-
-//===--- support/xlocale/xlocale.h ===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-// This is a shared implementation of a shim to provide extended locale support
-// on top of libc's that don't support it (like Android's bionic, and Newlib).
-//
-// The 'illusion' only works when the specified locale is "C" or "POSIX", but
-// that's about as good as we can do without implementing full xlocale support
-// in the underlying libc.
-//===--===//
-
-#ifndef _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H
-#define _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline int isalnum_l(int c, locale_t) {
-  return isalnum(c);
-}
-
-static inline int isalpha_l(int c, locale_t) {
-  return isalpha(c);
-}
-
-static inline int isblank_l(int c, locale_t) {
-  return isblank(c);
-}
-
-static inline int iscntrl_l(int c, locale_t) {
-  return iscntrl(c);
-}
-
-static inline int isdigit_l(int c, locale_t) {
-  return isdigit(c);
-}
-
-static inline int isgraph_l(int c, locale_t) {
-  return isgraph(c);
-}
-
-static inline int islower_l(int c, locale_t) {
-  return islower(c);
-}
-
-static inline int isprint_l(int c, locale_t) {
-  return isprint(c);
-}
-
-static inline int ispunct_l(int c, locale_t) {
-  return ispunct(c);
-}
-
-static inline int isspace_l(int c, locale_t) {
-  return isspace(c);
-}
-
-static inline int isupper_l(int c, locale_t) {
-  return isupper(c);
-}
-
-static inline int isxdigit_l(int c, locale_t) {
-  return isxdigit(c);
-}
-
-static inline int iswalnum_l(wint_t c, locale_t) {
-  return iswalnum(c);
-}
-
-static inline int iswalpha_l(wint_t c, locale_t) {
-  return iswalpha(c);
-}
-
-static inline int iswblank_l(wint_t c, locale_t) {
-  return iswblank(c);
-}
-
-static inline int iswcntrl_l(wint_t c, locale_t) {
-  return iswcntrl(c);
-}
-
-static inline int iswdigit_l(wint_t c, locale_t) {
-  return iswdigit(c);
-}
-
-static inline int iswgraph_l(wint_t c, locale_t) {
-  return iswgraph(c);
-}
-
-static inline int iswlower_l(wint_t c, locale_t) {
-  return iswlower(c);
-}
-
-static inline int iswprint_l(wint_t c, locale_t) {
-  return iswprint(c);
-}
-
-static inline int iswpunct_l(wint_t c, locale_t) {
-  return iswpunct(c);
-}
-
-static inline int iswspace_l(wint_t c, locale_t) {
-  return iswspace(c);
-}
-
-static inline int iswupper_l(wint_t c, locale_t) {
-  return iswupper(c);
-}
-
-static inline int iswxdigit_l(wint_t c, locale_t) {
-  return iswxdigit(c);
-}
-
-static inline int toupper_l(int c, locale_t) {
-  return toupper(c);
-}
-
-static inline int tolower_l(int c, locale_t) {
-  return tolower(c);
-}
-
-static inline int towupper_l(int c, locale_t) {
-  return towupper(c);
-}
-
-static inline int towlower_l(int c, locale_t) {
-  return towlower(c);
-}
-
-static inline int strcoll_l(const char *s1, const char *s2, locale_t) {
-  return strcoll(s1, s2);
-}
-
-static inline size_t strxfrm_l(char *dest, const char *src, size_t n,
-   locale_t) {
-  return strxfrm(dest, src, n);
-}
-
-static inline size_t strftime_l(char *s, size_t max, c

r261271 - Remove use of builtin comma operator.

2016-02-18 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Feb 18 16:34:54 2016
New Revision: 261271

URL: http://llvm.org/viewvc/llvm-project?rev=261271&view=rev
Log:
Remove use of builtin comma operator.

Cleanup for upcoming Clang warning -Wcomma.  No functionality change intended.

Modified:
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/PPExpressions.cpp
cfe/trunk/lib/Rewrite/RewriteRope.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=261271&r1=261270&r2=261271&view=diff
==
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Thu Feb 18 16:34:54 2016
@@ -190,13 +190,21 @@ clang::analyze_format_string::ParseLengt
   return false;
 case 'h':
   ++I;
-  lmKind = (I != E && *I == 'h') ? (++I, LengthModifier::AsChar)
- : LengthModifier::AsShort;
+  if (I != E && *I == 'h') {
+++I;
+lmKind = LengthModifier::AsChar;
+  } else {
+lmKind = LengthModifier::AsShort;
+  }
   break;
 case 'l':
   ++I;
-  lmKind = (I != E && *I == 'l') ? (++I, LengthModifier::AsLongLong)
- : LengthModifier::AsLong;
+  if (I != E && *I == 'l') {
+++I;
+lmKind = LengthModifier::AsLongLong;
+  } else {
+lmKind = LengthModifier::AsLong;
+  }
   break;
 case 'j': lmKind = LengthModifier::AsIntMax; ++I; break;
 case 'z': lmKind = LengthModifier::AsSizeT;  ++I; break;

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=261271&r1=261270&r2=261271&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Feb 18 16:34:54 2016
@@ -1258,15 +1258,19 @@ FoundSpecialChar:
 
 if (Buf[0] == '\n' || Buf[0] == '\r') {
   // If this is \n\r or \r\n, skip both characters.
-  if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1])
-++Offs, ++Buf;
-  ++Offs, ++Buf;
+  if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1]) {
+++Offs;
+++Buf;
+  }
+  ++Offs;
+  ++Buf;
   LineOffsets.push_back(Offs);
 } else {
   // Otherwise, this is a null.  If end of file, exit.
   if (Buf == End) break;
   // Otherwise, skip the null.
-  ++Offs, ++Buf;
+  ++Offs;
+  ++Buf;
 }
   }
 

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=261271&r1=261270&r2=261271&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Feb 18 16:34:54 2016
@@ -2760,7 +2760,8 @@ void CGOpenMPRuntime::emitTaskCall(
 PrivateHelpersTy(
 VD, cast(cast(*I)->getDecl()),
 cast(cast(*IElemInitRef)->getDecl();
-++I, ++IElemInitRef;
+++I;
+++IElemInitRef;
   }
   llvm::array_pod_sort(Privates.begin(), Privates.end(),
array_pod_sort_comparator);
@@ -3259,7 +3260,9 @@ static llvm::Value *emitReductionFunctio
 } else
   // Emit reduction for array subscript or single variable.
   CGF.EmitIgnoredExpr(E);
-++IPriv, ++ILHS, ++IRHS;
+++IPriv;
+++ILHS;
+++IRHS;
   }
   Scope.ForceCleanup();
   CGF.FinishFunction();
@@ -3326,7 +3329,9 @@ void CGOpenMPRuntime::emitReduction(Code
 const Expr *) { CGF.EmitIgnoredExpr(E); });
   } else
 CGF.EmitIgnoredExpr(E);
-  ++IPriv, ++ILHS, ++IRHS;
+  ++IPriv;
+  ++ILHS;
+  ++IRHS;
 }
 return;
   }
@@ -3444,7 +3449,9 @@ void CGOpenMPRuntime::emitReduction(Code
   } else
 // Emit reduction for array subscript or single variable.
 CGF.EmitIgnoredExpr(E);
-  ++IPriv, ++ILHS, ++IRHS;
+  ++IPriv;
+  ++ILHS;
+  ++IRHS;
 }
   }
 
@@ -3553,7 +3560,9 @@ void CGOpenMPRuntime::emitReduction(Code
   } else
 CritRedGen(CGF, nullptr, nullptr, nullptr);
 }
-  ++ILHS, ++IRHS, ++IPriv;
+  ++ILHS;
+  ++IRHS;
+  ++IPriv;
 }
   }
 

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

[PATCH] D17418: [analyzer] Add checker callback for beginning of function.

2016-02-18 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added a reviewer: zaks.anna.
dcoughlin added a subscriber: cfe-commits.

Add a checker callback that is called when the analyzer starts analyzing a
function either at the top level or when inlined. This will be used by a
follow-on patch making the DeallocChecker path sensitive.

http://reviews.llvm.org/D17418

Files:
  include/clang/Analysis/ProgramPoint.h
  include/clang/StaticAnalyzer/Core/Checker.h
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
  lib/StaticAnalyzer/Core/CheckerManager.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/traversal-begin-end-function.c
  test/Analysis/traversal-path-unification.c

Index: test/Analysis/traversal-path-unification.c
===
--- test/Analysis/traversal-path-unification.c
+++ test/Analysis/traversal-path-unification.c
@@ -11,6 +11,7 @@
 #define CHECK(x) (x)
 #endif
 
+// CHECK: --BEGIN FUNCTION--
 void testRemoveDeadBindings() {
   int i = a();
   if (CHECK(i))
Index: test/Analysis/traversal-begin-end-function.c
===
--- /dev/null
+++ test/Analysis/traversal-begin-end-function.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.DumpTraversal %s | FileCheck %s
+
+void inline_callee(int i);
+
+// CHECK: --BEGIN FUNCTION--
+void inline_caller() {
+  // CHECK: --BEGIN FUNCTION--
+  // CHECK: --BEGIN FUNCTION--
+  // CHECK: --BEGIN FUNCTION--
+  inline_callee(3);
+  // CHECK: --END FUNCTION--
+  // CHECK: --END FUNCTION--
+  // CHECK: --END FUNCTION--
+}
+// CHECK: --END FUNCTION--
+
+void inline_callee(int i) {
+  if (i <= 1)
+return;
+
+  inline_callee(i - 1);
+}
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -37,13 +37,12 @@
 STATISTIC(NumReachedInlineCountMax,
   "The # of times we reached inline count maximum");
 
-void ExprEngine::processCallEnter(CallEnter CE, ExplodedNode *Pred) {
+void ExprEngine::processCallEnter(NodeBuilderContext& BC, CallEnter CE,
+  ExplodedNode *Pred) {
   // Get the entry block in the CFG of the callee.
   const StackFrameContext *calleeCtx = CE.getCalleeContext();
   PrettyStackTraceLocationContext CrashInfo(calleeCtx);
-
-  const CFG *CalleeCFG = calleeCtx->getCFG();
-  const CFGBlock *Entry = &(CalleeCFG->getEntry());
+  const CFGBlock *Entry = CE.getEntry();
 
   // Validate the CFG.
   assert(Entry->empty());
@@ -61,8 +60,11 @@
   bool isNew;
   ExplodedNode *Node = G.getNode(Loc, state, false, &isNew);
   Node->addPredecessor(Pred, G);
-  if (isNew)
-Engine.getWorkList()->enqueue(Node);
+  if (isNew) {
+ExplodedNodeSet DstBegin;
+processBeginOfFunction(BC, Node, DstBegin, Loc);
+Engine.enqueue(DstBegin);
+  }
 }
 
 // Find the last statement on the path to the exploded node and the
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -30,6 +30,7 @@
 #include "llvm/ADT/ImmutableList.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/SaveAndRestore.h"
 
 #ifndef NDEBUG
 #include "llvm/Support/GraphWriter.h"
@@ -1749,6 +1750,14 @@
 }
 #endif
 
+void ExprEngine::processBeginOfFunction(NodeBuilderContext &BC,
+ExplodedNode *Pred,
+ExplodedNodeSet &Dst,
+const BlockEdge &L) {
+  SaveAndRestore NodeContextRAII(currBldrCtx, &BC);
+  getCheckerManager().runCheckersForBeginFunction(Dst, L, Pred, *this);
+}
+
 /// ProcessEndPath - Called by CoreEngine.  Used to generate end-of-path
 ///  nodes when the control reaches the end of a function.
 void ExprEngine::processEndOfFunction(NodeBuilderContext& BC,
Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -192,10 +192,18 @@
 WList->setBlockCounter(BCounterFactory.GetEmptyCounter());
 
 if (!InitState)
-  // Generate the root.
-  generateNode(StartLoc, SubEng.getInitialState(L), nullptr);
-else
-  generateNode(StartLoc, InitState, nullptr);
+  InitState = SubEng.getInitialState(

Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-18 Thread H.J. Lu via cfe-commits
On Thu, Feb 18, 2016 at 6:35 AM, Michael Matz  wrote:
> Hi,
>
> On Tue, 16 Feb 2016, H.J. Lu wrote:
>
>> Here is the new definition:
>>
>> An empty type is a type where it and all of its subobjects (recursively)
>> are of class, structure, union, or array type.  No memory slot nor
>> register should be used to pass or return an object of empty type.
>
> The trivially copyable is gone again.  Why is it not necessary?
>

I think we want to cover

struct
{
  unsigned int : 8;
};

but not

struct
{
  unsigned int  i :8;
};

" trivially copyable" applies to both.

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


  1   2   >