[libunwind] r314196 - Correct data types in the _Unwind_FunctionContext struct

2017-09-26 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Sep 26 01:07:17 2017
New Revision: 314196

URL: http://llvm.org/viewvc/llvm-project?rev=314196&view=rev
Log:
Correct data types in the _Unwind_FunctionContext struct

This makes it match the definition used within llvm and in libgcc,
we previously got the wrong layout in 64 bit environments.

Differential Revision: https://reviews.llvm.org/D38247

Modified:
libunwind/trunk/src/Unwind-sjlj.c

Modified: libunwind/trunk/src/Unwind-sjlj.c
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-sjlj.c?rev=314196&r1=314195&r2=314196&view=diff
==
--- libunwind/trunk/src/Unwind-sjlj.c (original)
+++ libunwind/trunk/src/Unwind-sjlj.c Tue Sep 26 01:07:17 2017
@@ -39,10 +39,10 @@ struct _Unwind_FunctionContext {
   struct _Unwind_FunctionContext *prev;
 
   // set by calling function before registering to be the landing pad
-  uintptr_t   resumeLocation;
+  uint32_tresumeLocation;
 
   // set by personality handler to be parameters passed to landing pad function
-  uintptr_t   resumeParameters[4];
+  uint32_tresumeParameters[4];
 
   // set by calling function before registering
   __personality_routine   personality; // arm offset=24


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


[libunwind] r314197 - Skip building unused parts when targeting SJLJ

2017-09-26 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Sep 26 01:07:26 2017
New Revision: 314197

URL: http://llvm.org/viewvc/llvm-project?rev=314197&view=rev
Log:
Skip building unused parts when targeting SJLJ

When SJLJ exceptions are used, those functions aren't used.

This fixes build failures on ARM with SJLJ enabled (e.g. on armv7/iOS)
when built using the CMake project files.

Differential Revision: https://reviews.llvm.org/D38249

Modified:
libunwind/trunk/src/UnwindLevel1.c
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/src/UnwindLevel1.c
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindLevel1.c?rev=314197&r1=314196&r2=314197&view=diff
==
--- libunwind/trunk/src/UnwindLevel1.c (original)
+++ libunwind/trunk/src/UnwindLevel1.c Tue Sep 26 01:07:26 2017
@@ -30,7 +30,7 @@
 #include "unwind.h"
 #include "config.h"
 
-#if !defined(_LIBUNWIND_ARM_EHABI)
+#if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
 
 static _Unwind_Reason_Code
 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception 
*exception_object) {
@@ -503,4 +503,4 @@ _LIBUNWIND_EXPORT void _Unwind_SetIP(str
   unw_set_reg(cursor, UNW_REG_IP, value);
 }
 
-#endif // !defined(_LIBUNWIND_ARM_EHABI)
+#endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)

Modified: libunwind/trunk/src/UnwindRegistersRestore.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersRestore.S?rev=314197&r1=314196&r2=314197&view=diff
==
--- libunwind/trunk/src/UnwindRegistersRestore.S (original)
+++ libunwind/trunk/src/UnwindRegistersRestore.S Tue Sep 26 01:07:26 2017
@@ -308,7 +308,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
   ldpx0, x1,  [x0, #0x000]  // restore x0,x1
   retx30// jump to pc
 
-#elif defined(__arm__) && !defined(__APPLE__)
+#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb

Modified: libunwind/trunk/src/UnwindRegistersSave.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=314197&r1=314196&r2=314197&view=diff
==
--- libunwind/trunk/src/UnwindRegistersSave.S (original)
+++ libunwind/trunk/src/UnwindRegistersSave.S Tue Sep 26 01:07:26 2017
@@ -289,7 +289,7 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
   movx0, #0   // return UNW_ESUCCESS
   ret
 
-#elif defined(__arm__) && !defined(__APPLE__)
+#elif defined(__arm__) && !(defined(__APPLE__) || 
defined(__USING_SJLJ_EXCEPTIONS__))
 
 #if !defined(__ARM_ARCH_ISA_ARM)
   .thumb

Modified: libunwind/trunk/src/libunwind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=314197&r1=314196&r2=314197&view=diff
==
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Tue Sep 26 01:07:26 2017
@@ -24,6 +24,7 @@
 #include 
 
 
+#if !defined(__USING_SJLJ_EXCEPTIONS__)
 #include "AddressSpace.hpp"
 #include "UnwindCursor.hpp"
 
@@ -341,6 +342,7 @@ void _unw_remove_dynamic_fde(unw_word_t
   
DwarfFDECache::removeAllIn((LocalAddressSpace::pint_t)fde);
 }
 #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+#endif // !defined(__USING_SJLJ_EXCEPTIONS__)
 
 
 


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


r314205 - [OPENMP] Generate implicit map|firstprivate clauses for target-based

2017-09-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 26 06:47:31 2017
New Revision: 314205

URL: http://llvm.org/viewvc/llvm-project?rev=314205&view=rev
Log:
[OPENMP] Generate implicit map|firstprivate clauses for target-based
directives.

If the variable is used in the target-based region but is not found in
any private|mapping clause, then generate implicit firstprivate|map
clauses for these implicitly mapped variables.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp
cfe/trunk/test/OpenMP/target_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_shared_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_shared_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_shared_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_shared_messages.cpp
cfe/trunk/test/OpenMP/teams_shared_messages.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=314205&r1=314204&r2=314205&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Sep 26 06:47:31 2017
@@ -862,18 +862,7 @@ static void EmitOMPAggregateInit(CodeGen
 }
 
 LValue ReductionCodeGen::emitSharedLValue(CodeGenFunction &CGF, const Expr *E) 
{
-  if (const auto *OASE = dyn_cast(E))
-return CGF.EmitOMPArraySectionExpr(OASE);
-  if (const auto *ASE = dyn_cast(E))
-return CGF.EmitLValue(ASE);
-  auto *OrigVD = cast(cast(E)->getDecl());
-  DeclRefExpr DRE(const_cast(OrigVD),
-  CGF.CapturedStmtInfo &&
-  CGF.CapturedStmtInfo->lookup(OrigVD) != nullptr,
-  E->getType(), VK_LValue, E->getExprLoc());
-  // Store the address of the original variable associated with the LHS
-  // implicit variable.
-  return CGF.EmitLValue(&DRE);
+  return CGF.EmitOMPSharedLValue(E);
 }
 
 LValue ReductionCodeGen::emitSharedLValueUB(CodeGenFunction &CGF,
@@ -5978,6 +5967,8 @@ public:
 OMP_MAP_PRIVATE_PTR = 0x80,
 /// \brief Pass the element to the device by value.
 OMP_MAP_PRIVATE_VAL = 0x100,
+/// Implicit map
+OMP_MAP_IMPLICIT = 0x200,
   };
 
   /// Class that associates information with a base pointer to be passed to the
@@ -6148,7 +6139,7 @@ private:
   OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
   MapBaseValuesArrayTy &BasePointers, MapValuesArrayTy &Pointers,
   MapValuesArrayTy &Sizes, MapFlagsArrayTy &Types,
-  bool IsFirstComponentList) const {
+  bool IsFirstComponentList, bool IsImplicit) const {
 
 // The following summarizes what has to be generated for each map and the
 // types bellow. The generated information is expressed in this order:
@@ -6283,8 +6274,7 @@ private:
 } else {
   // The base is the reference to the variable.
   // BP = &Var.
-  BP = CGF.EmitLValue(cast(I->getAssociatedExpression()))
-   .getPointer();
+  BP = CGF.EmitOMPSharedLValue(I->getAssociatedExpression()).getPointer();
 
   // If the variable is a pointer and is being dereferenced (i.e. is not
   // the last component), the base has to be the pointer itself, not its
@@ -6303,6 +6293,7 @@ private:
   }
 }
 
+unsigned DefaultFlags = IsImplicit ? OMP_MAP_IMPLICIT : 0;
 for (; I != CE; ++I) {
   auto Next = std::next(I);
 
@@ -6337,7 +6328,8 @@ private:
 isa(Next->getAssociatedExpression())) &&
"Unexpected expression");
 
-auto *LB = CGF.EmitLValue(I->getAssociatedExpression()).getPointer();
+llvm::Value *LB =
+CGF.EmitOMPSharedLValue(I->getAssociatedExpression()).getPointer();
 auto *Size = getExprTypeSize(I->getAssociatedExpression());
 
 // If we have a member expression and the current component is a
@@ -6352,9 +6344,11 @@ private:
   BasePointers.push_back(BP);
   Pointers.push_back(RefAddr);
   Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
-  Types.push_back(getMapTypeBits(
-  /*MapType*/ OMPC_MAP_alloc, /*MapTypeModifier=*/OMPC_MAP_unknown,
-  !IsExpressionFirstInfo, IsCaptureFirstInfo));
+  Types.push_back(DefaultFlags |
+  getMapTypeBits(
+  /*MapType*/ OMPC_MAP_alloc,
+  /*MapTypeModifier=*/OMPC_MAP_unknown,
+  !IsExpressionFirstInfo, IsCaptureFirstInfo));
   IsExpressionFirstInfo = 

r314209 - Fix TBAA information for reference accesses

2017-09-26 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Tue Sep 26 07:22:48 2017
New Revision: 314209

URL: http://llvm.org/viewvc/llvm-project?rev=314209&view=rev
Log:
Fix TBAA information for reference accesses

This patch fixes clang to decorate reference accesses as pointers
and not as "omnipotent chars".

Differential Revision: https://reviews.llvm.org/D38074

Added:
cfe/trunk/test/CodeGen/tbaa-reference.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=314209&r1=314208&r2=314209&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Tue Sep 26 07:22:48 2017
@@ -145,10 +145,10 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
   if (Ty->isStdByteType())
 return MetadataCache[Ty] = getChar();
 
-  // Handle pointers.
+  // Handle pointers and references.
   // TODO: Implement C++'s type "similarity" and consider dis-"similar"
   // pointers distinct.
-  if (Ty->isPointerType())
+  if (Ty->isPointerType() || Ty->isReferenceType())
 return MetadataCache[Ty] = createTBAAScalarType("any pointer",
 getChar());
 

Added: cfe/trunk/test/CodeGen/tbaa-reference.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-reference.cpp?rev=314209&view=auto
==
--- cfe/trunk/test/CodeGen/tbaa-reference.cpp (added)
+++ cfe/trunk/test/CodeGen/tbaa-reference.cpp Tue Sep 26 07:22:48 2017
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm 
-o - | FileCheck %s
+//
+// Check that we generate correct TBAA information for reference accesses.
+
+struct S;
+
+struct B {
+  S &s;
+  B(S &s) : s(s) {}
+  void bar();
+};
+
+void foo(S &s) {
+  B b(s);
+  b.bar();
+}
+
+// CHECK-LABEL: _Z3fooR1S
+// Check initialization of the reference parameter in foo().
+// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa 
[[TAG_pointer:!.*]]
+//
+// CHECK-LABEL: _ZN1BC2ER1S
+// TODO: Check loading of the reference parameter in B::B(S&).
+// Check initialization of B::s in B::B(S&).
+// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa [[TAG_pointer]]
+//
+// CHECK-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 
0}
+// CHECK-DAG: [[TYPE_pointer]] = !{!"any pointer", [[TYPE_char:!.*]], i64 0}
+// CHECK-DAG: [[TYPE_char]] = !{!"omnipotent char", {{!.*}}, i64 0}


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


r314211 - [clang-format] Add ext/ to google include categories

2017-09-26 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Sep 26 07:58:29 2017
New Revision: 314211

URL: http://llvm.org/viewvc/llvm-project?rev=314211&view=rev
Log:
[clang-format] Add ext/ to google include categories

Summary: This adds an ext/ header include category for google style.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D38243

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=314211&r1=314210&r2=314211&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Sep 26 07:58:29 2017
@@ -665,7 +665,8 @@ FormatStyle getGoogleStyle(FormatStyle::
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
-  GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeCategories = {
+  {"^", 2}, {"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;


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


r314213 - [mips] Accept but ignore -m(no-)branch-likely

2017-09-26 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Tue Sep 26 08:01:21 2017
New Revision: 314213

URL: http://llvm.org/viewvc/llvm-project?rev=314213&view=rev
Log:
[mips] Accept but ignore -m(no-)branch-likely

-mbranch-likely and -mno-branch-likely are used in some build systems for
some MIPS targets. Accept these options but ignore them as they are an
(de)optimiztion hint, and that branch likely instructions were deprecated
but not removed from MIPS32 and MIPS64 ISAs.

Reviewers: atanasyan, nitesh.jain

Differential Revision: https://reviews.llvm.org/D38168

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=314213&r1=314212&r2=314213&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Sep 26 08:01:21 2017
@@ -2047,6 +2047,10 @@ def mcheck_zero_division : Flag<["-"], "
 def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">,
   Group;
 def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group;
+def mbranch_likely : Flag<["-"], "mbranch-likely">, Group,
+  IgnoredGCCCompat;
+def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group,
+  IgnoredGCCCompat;
 def mdsp : Flag<["-"], "mdsp">, Group;
 def mno_dsp : Flag<["-"], "mno-dsp">, Group;
 def mdspr2 : Flag<["-"], "mdspr2">, Group;

Modified: cfe/trunk/test/Driver/mips-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=314213&r1=314212&r2=314213&view=diff
==
--- cfe/trunk/test/Driver/mips-features.c (original)
+++ cfe/trunk/test/Driver/mips-features.c Tue Sep 26 08:01:21 2017
@@ -392,3 +392,13 @@
 // LONG-CALLS-ON: "-target-feature" "+long-calls"
 // LONG-CALLS-OFF: "-target-feature" "-long-calls"
 // LONG-CALLS-DEF-NOT: "long-calls"
+//
+// -mbranch-likely
+// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \
+// RUN:   | FileCheck --check-prefix=BRANCH-LIKELY %s
+// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely'
+//
+// -mno-branch-likely
+// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \
+// RUN:   | FileCheck --check-prefix=NO-BRANCH-LIKELY %s
+// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely'


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


r314218 - [analyzer] Keep track of design discusions as part of analyzer documentation.

2017-09-26 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Sep 26 08:49:53 2017
New Revision: 314218

URL: http://llvm.org/viewvc/llvm-project?rev=314218&view=rev
Log:
[analyzer] Keep track of design discusions as part of analyzer documentation.

Create a directory to store discussions on potentially useful features that are
not yet implemented in the analyzer.

Fill it with a discussion on representing checker-specific parts of the program
state for C++ object modeling, that occured in D35216.

Differential Revision: https://reviews.llvm.org/D36737

Added:
cfe/trunk/docs/analyzer/DesignDiscussions/
cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst

Added: cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst?rev=314218&view=auto
==
--- cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst (added)
+++ cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst Tue Sep 26 
08:49:53 2017
@@ -0,0 +1,321 @@
+This discussion took place in https://reviews.llvm.org/D35216
+"Escape symbols when creating std::initializer_list".
+
+It touches problems of modelling C++ standard library constructs in general,
+including modelling implementation-defined fields within C++ standard library
+objects, in particular constructing objects into pointers held by such fields,
+and separation of responsibilities between analyzer's core and checkers.
+
+**Artem:**
+
+I've seen a few false positives that appear because we construct
+C++11 std::initializer_list objects with brace initializers, and such
+construction is not properly modeled. For instance, if a new object is
+constructed on the heap only to be put into a brace-initialized STL container,
+the object is reported to be leaked.
+
+Approach (0): This can be trivially fixed by this patch, which causes pointers
+passed into initializer list expressions to immediately escape.
+
+This fix is overly conservative though. So i did a bit of investigation as to
+how model std::initializer_list better.
+
+According to the standard, std::initializer_list is an object that has
+methods begin(), end(), and size(), where begin() returns a pointer to 
continous
+array of size() objects of type T, and end() is equal to begin() plus size().
+The standard does hint that it should be possible to implement
+std::initializer_list as a pair of pointers, or as a pointer and a size
+integer, however specific fields that the object would contain are an
+implementation detail.
+
+Ideally, we should be able to model the initializer list's methods precisely.
+Or, at least, it should be possible to explain to the analyzer that the list
+somehow "takes hold" of the values put into it. Initializer lists can also be
+copied, which is a separate story that i'm not trying to address here.
+
+The obvious approach to modeling std::initializer_list in a checker would be to
+construct a SymbolMetadata for the memory region of the initializer list 
object,
+which would be of type T* and represent begin(), so we'd trivially model 
begin()
+as a function that returns this symbol. The array pointed to by that symbol
+would be bindLoc()ed to contain the list's contents (probably as a CompoundVal
+to produce less bindings in the store). Extent of this array would represent
+size() and would be equal to the length of the list as written.
+
+So this sounds good, however apparently it does nothing to address our false
+positives: when the list escapes, our RegionStoreManager is not magically
+guessing that the metadata symbol attached to it, together with its contents,
+should also escape. In fact, it's impossible to trigger a pointer escape from
+within the checker.
+
+Approach (1): If only we enabled ProgramState::bindLoc(..., notifyChanges=true)
+to cause pointer escapes (not only region changes) (which sounds like the right
+thing to do anyway) such checker would be able to solve the false positives by
+triggering escapes when binding list elements to the list. However, it'd be as
+conservative as the current patch's solution. Ideally, we do not want escapes 
to
+happen so early. Instead, we'd prefer them to be delayed until the list itself
+escapes.
+
+So i believe that escaping metadata symbols whenever their base regions escape
+would be the right thing to do. Currently we didn't think about that because we
+had neither pointer-type metadatas nor non-pointer escapes.
+
+Approach (2): We could teach the Store to scan itself for bindings to
+metadata-symbolic-based regions during scanReachableSymbols() whenever a region
+turns out to be reachable. This requires no work on checker side, but it sounds
+performance-heavy.
+
+Approach (3): We could let checkers maintain the set of active metadata symbols
+in the program state (ideally somewhere in the Store, which sounds weird but
+causes the smallest amount of layering violation

Re: r309386 - Recommit r308327 3rd time: Add a warning for missing

2017-09-26 Thread Nico Weber via cfe-commits
Another bit of feedback: The Microsoft SDK has pragma adjustment headers
that are used like so:

#include 
// Define structs with alignment 1 here
#include 

This warning fires on that. I haven't seen these headers in active use
recently, but I remember seeing them quite a bit maybe 10 years ago. (It
took me until today to remember their names.) Any ideas on how to deal with
that?

On Fri, Jul 28, 2017 at 2:41 PM, Alex Lorenz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arphaman
> Date: Fri Jul 28 07:41:21 2017
> New Revision: 309386
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309386&view=rev
> Log:
> Recommit r308327 3rd time: Add a warning for missing
> '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included
> files
>
> The second recommit (r309106) was reverted because the "non-default #pragma
> pack value chages the alignment of struct or union members in the included
> file"
> warning proved to be too aggressive for external projects like Chromium
> (https://bugs.chromium.org/p/chromium/issues/detail?id=749197). This
> recommit
> makes the problematic warning a non-default one, and gives it the
> -Wpragma-pack-suspicious-include warning option.
>
> The first recommit (r308441) caused a "non-default #pragma pack value might
> change the alignment of struct or union members in the included file"
> warning
> in LLVM itself. This recommit tweaks the added warning to avoid warnings
> for
> #includes that don't have any records that are affected by the non-default
> alignment. This tweak avoids the previously emitted warning in LLVM.
>
> Original message:
>
> This commit adds a new -Wpragma-pack warning. It warns in the following
> cases:
>
> - When a translation unit is missing terminating #pragma pack (pop)
> directives.
> - When entering an included file if the current alignment value as
> determined
>   by '#pragma pack' directives is different from the default alignment
> value.
> - When leaving an included file that changed the state of the current
> alignment
>   value.
>
> rdar://10184173
>
> Differential Revision: https://reviews.llvm.org/D35484
>
> Added:
> cfe/trunk/test/PCH/suspicious-pragma-pack.c
> cfe/trunk/test/Sema/Inputs/pragma-pack1.h
> cfe/trunk/test/Sema/Inputs/pragma-pack2.h
> cfe/trunk/test/Sema/suspicious-pragma-pack.c
> cfe/trunk/test/SemaObjC/Inputs/empty.h
> cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Lex/PPCallbacks.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/lib/Parse/ParsePragma.cpp
> cfe/trunk/lib/Sema/Sema.cpp
> cfe/trunk/lib/Sema/SemaAttr.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/OpenMP/declare_simd_messages.cpp
> cfe/trunk/test/PCH/pragma-pack.c
> cfe/trunk/test/Parser/pragma-options.c
> cfe/trunk/test/Parser/pragma-options.cpp
> cfe/trunk/test/Parser/pragma-pack.c
> cfe/trunk/test/Sema/pragma-pack.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/DiagnosticGroups.td?rev=309386&r1=309385&r2=309386&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jul 28 07:41:21
> 2017
> @@ -471,8 +471,10 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
>  def UnknownPragmas : DiagGroup<"unknown-pragmas">;
>  def IgnoredPragmas : DiagGroup<"ignored-pragmas",
> [IgnoredPragmaIntrinsic]>;
>  def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
> +def PragmaPackSuspiciousInclude : DiagGroup<"pragma-pack-
> suspicious-include">;
> +def PragmaPack : DiagGroup<"pragma-pack", [PragmaPackSuspiciousInclude]>;
>  def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
> -PragmaClangAttribute]>;
> +PragmaClangAttribute, PragmaPack]>;
>  def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
>  def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
>  def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=309386&r1=309385&r2=309386&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 28
> 07:41:21 2017
> @@ -712,6 +712,17 @@ def err_pragma_options_align_mac68k_targ
>  def warn_pragma_pack_i

r314220 - [OPENMP] Fix handling of implicit mapping of array sections.

2017-09-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 26 09:19:04 2017
New Revision: 314220

URL: http://llvm.org/viewvc/llvm-project?rev=314220&view=rev
Log:
[OPENMP] Fix handling of implicit mapping of array sections.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_map_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=314220&r1=314219&r2=314220&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Sep 26 09:19:04 2017
@@ -1972,9 +1972,8 @@ public:
   OMPClauseMappableExprCommon::MappableExprComponentListRef
   StackComponents,
   OpenMPClauseKind) {
-if (CurComponents.size() < StackComponents.size())
-  return false;
 auto CCI = CurComponents.rbegin();
+auto CCE = CurComponents.rend();
 for (const auto &SC : llvm::reverse(StackComponents)) {
   // Do both expressions have the same kind?
   if (CCI->getAssociatedExpression()->getStmtClass() !=
@@ -1992,6 +1991,8 @@ public:
   if (SCD != CCD)
 return false;
   std::advance(CCI, 1);
+  if (CCI == CCE)
+break;
 }
 return true;
   })) {

Modified: cfe/trunk/test/OpenMP/target_map_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_messages.cpp?rev=314220&r1=314219&r2=314220&view=diff
==
--- cfe/trunk/test/OpenMP/target_map_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_messages.cpp Tue Sep 26 09:19:04 2017
@@ -592,6 +592,8 @@ int main(int argc, char **argv) {
 #pragma omp target map(s.p->p->p->a)
 // expected-error@+1 {{variable already marked as mapped in current construct}}
   { s.a++; }
+#pragma omp target map(s.s.s.b[:2])
+  { s.s.s.b[0]++; }
 
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }


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


r314223 - [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-26 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Sep 26 10:07:23 2017
New Revision: 314223

URL: http://llvm.org/viewvc/llvm-project?rev=314223&view=rev
Log:
[NVPTX] added match.{any,all}.sync instructions, intrinsics & builtins.

Differential Revision: https://reviews.llvm.org/D38191

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=314223&r1=314222&r2=314223&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Tue Sep 26 10:07:23 2017
@@ -413,6 +413,13 @@ TARGET_BUILTIN(__nvvm_vote_any_sync, "bU
 TARGET_BUILTIN(__nvvm_vote_uni_sync, "bUib", "", "ptx60")
 TARGET_BUILTIN(__nvvm_vote_ballot_sync, "UiUib", "", "ptx60")
 
+// Match
+TARGET_BUILTIN(__nvvm_match_any_sync_i32, "UiUiUi", "", "ptx60")
+TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", "ptx60")
+// These return a pair {value, predicate}, which requires custom lowering.
+TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", "ptx60")
+TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "WiUiWii*", "", "ptx60")
+
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=314223&r1=314222&r2=314223&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Sep 26 10:07:23 2017
@@ -9589,6 +9589,21 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
 {Ptr->getType()->getPointerElementType(), Ptr->getType()}),
 {Ptr, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2))});
   }
+  case NVPTX::BI__nvvm_match_all_sync_i32p:
+  case NVPTX::BI__nvvm_match_all_sync_i64p: {
+Value *Mask = EmitScalarExpr(E->getArg(0));
+Value *Val = EmitScalarExpr(E->getArg(1));
+Address PredOutPtr = EmitPointerWithAlignment(E->getArg(2));
+Value *ResultPair = Builder.CreateCall(
+CGM.getIntrinsic(BuiltinID == NVPTX::BI__nvvm_match_all_sync_i32p
+ ? Intrinsic::nvvm_match_all_sync_i32p
+ : Intrinsic::nvvm_match_all_sync_i64p),
+{Mask, Val});
+Value *Pred = Builder.CreateZExt(Builder.CreateExtractValue(ResultPair, 1),
+ PredOutPtr.getElementType());
+Builder.CreateStore(Pred, PredOutPtr);
+return Builder.CreateExtractValue(ResultPair, 0);
+  }
   default:
 return nullptr;
   }

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=314223&r1=314222&r2=314223&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Tue Sep 26 10:07:23 2017
@@ -92,8 +92,9 @@ __MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
+#if CUDA_VERSION >= 9000
+#if (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
 // __shfl_sync_* variants available in CUDA-9
-#if CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
 #pragma push_macro("__MAKE_SYNC_SHUFFLES")
 #define __MAKE_SYNC_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic,   
\
  __Mask)   
\
@@ -187,8 +188,33 @@ inline __device__ unsigned int __ballot_
 
 inline __device__ unsigned int activemask() { return __nvvm_vote_ballot(1); }
 
-#endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) ||
-   // __CUDA_ARCH__ >= 300)
+#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
+
+// Define __match* builtins CUDA-9 headers expect to see.
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700
+inline __device__ unsigned int __match32_any_sync(unsigned int mask,
+  unsigned int value) {
+  return __nvvm_match_any_sync_i32(mask, value);
+}
+
+inline __device__ unsigned long long
+__match64_any_sync(unsigned int mask, unsigned long long value) {
+  return __nvvm_match_any_sync_i64(mask, value);
+}
+
+inline __device__ unsigned int
+__match32_all_sync(unsigned int mask, unsigned int value, int *pred) {
+  return __nvvm_match_all_sync_i32p(mask, value, pred);
+}
+
+inline __device__ unsigned long long
+__match64_all_sync(unsigned int mask, unsigned long long value, int *pred) {
+  return __nvvm_match_all_sync_i64p(mask, value, pred);
+}
+#include "crt/sm_70_rt.hpp"
+
+#endif // !defined(__CUDA_AR

r314226 - Sema: Windows/ARM __va_start is not const correct

2017-09-26 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Sep 26 10:44:10 2017
New Revision: 314226

URL: http://llvm.org/viewvc/llvm-project?rev=314226&view=rev
Log:
Sema: Windows/ARM __va_start is not const correct

The `__va_start` intrinsic for Windows ARM does not account for const
correctness when performing a check.  All local qualifiers are ignored
when validating the invocation.  This was exposed by building the swift
stdlib against the Windows 10586 SDK for ARM.  Simply expand out the
check for the two parameters and ignore the qualifiers for the check.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/microsoft-varargs.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=314226&r1=314225&r2=314226&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Sep 26 10:44:10 2017
@@ -3943,23 +3943,33 @@ bool Sema::SemaBuiltinVAStartARM(CallExp
   if (checkVAStartIsInVariadicFunction(*this, Func))
 return true;
 
-  const struct {
-unsigned ArgNo;
-QualType Type;
-  } ArgumentTypes[] = {
-{ 1, Context.getPointerType(Context.CharTy.withConst()) },
-{ 2, Context.getSizeType() },
-  };
-
-  for (const auto &AT : ArgumentTypes) {
-const Expr *Arg = Call->getArg(AT.ArgNo)->IgnoreParens();
-if (Arg->getType().getCanonicalType() == AT.Type.getCanonicalType())
-  continue;
-Diag(Arg->getLocStart(), diag::err_typecheck_convert_incompatible)
-  << Arg->getType() << AT.Type << 1 /* different class */
-  << 0 /* qualifier difference */ << 3 /* parameter mismatch */
-  << AT.ArgNo + 1 << Arg->getType() << AT.Type;
-  }
+  // __va_start on Windows does not validate the parameter qualifiers
+
+  const Expr *Arg1 = Call->getArg(1)->IgnoreParens();
+  const Type *Arg1Ty = Arg1->getType().getCanonicalType().getTypePtr();
+
+  const Expr *Arg2 = Call->getArg(2)->IgnoreParens();
+  const Type *Arg2Ty = Arg2->getType().getCanonicalType().getTypePtr();
+
+  const QualType &ConstCharPtrTy =
+  Context.getPointerType(Context.CharTy.withConst());
+  if (!Arg1Ty->isPointerType() ||
+  Arg1Ty->getPointeeType().withoutLocalFastQualifiers() != Context.CharTy)
+Diag(Arg1->getLocStart(), diag::err_typecheck_convert_incompatible)
+<< Arg1->getType() << ConstCharPtrTy
+<< 1 /* different class */
+<< 0 /* qualifier difference */
+<< 3 /* parameter mismatch */
+<< 2 << Arg1->getType() << ConstCharPtrTy;
+
+  const QualType SizeTy = Context.getSizeType();
+  if (Arg2Ty->getCanonicalTypeInternal().withoutLocalFastQualifiers() != 
SizeTy)
+Diag(Arg2->getLocStart(), diag::err_typecheck_convert_incompatible)
+<< Arg2->getType() << SizeTy
+<< 1 /* different class */
+<< 0 /* qualifier difference */
+<< 3 /* parameter mismatch */
+<< 3 << Arg2->getType() << SizeTy;
 
   return false;
 }

Modified: cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/microsoft-varargs.cpp?rev=314226&r1=314225&r2=314226&view=diff
==
--- cfe/trunk/test/SemaCXX/microsoft-varargs.cpp (original)
+++ cfe/trunk/test/SemaCXX/microsoft-varargs.cpp Tue Sep 26 10:44:10 2017
@@ -20,3 +20,8 @@ int builtin(int i, ...) {
   return __builtin_va_arg(ap, int);
 }
 
+void test___va_start_ignore_const(const char *format, ...) {
+  va_list args;
+  ((void)(__va_start(&args, (&const_cast(reinterpret_cast(format))), ((sizeof(format) + 4 - 1) & ~(4 - 1)), 
(&const_cast(reinterpret_cast(format));
+}
+


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


Re: r314226 - Sema: Windows/ARM __va_start is not const correct

2017-09-26 Thread David Majnemer via cfe-commits
Shouldn't you only loosen the check for things targeting the Windows SDK?
GNU platforms shouldn't need this.

On Tue, Sep 26, 2017 at 10:44 AM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Tue Sep 26 10:44:10 2017
> New Revision: 314226
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314226&view=rev
> Log:
> Sema: Windows/ARM __va_start is not const correct
>
> The `__va_start` intrinsic for Windows ARM does not account for const
> correctness when performing a check.  All local qualifiers are ignored
> when validating the invocation.  This was exposed by building the swift
> stdlib against the Windows 10586 SDK for ARM.  Simply expand out the
> check for the two parameters and ignore the qualifiers for the check.
>
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaChecking.cpp?rev=314226&r1=314225&r2=314226&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Sep 26 10:44:10 2017
> @@ -3943,23 +3943,33 @@ bool Sema::SemaBuiltinVAStartARM(CallExp
>if (checkVAStartIsInVariadicFunction(*this, Func))
>  return true;
>
> -  const struct {
> -unsigned ArgNo;
> -QualType Type;
> -  } ArgumentTypes[] = {
> -{ 1, Context.getPointerType(Context.CharTy.withConst()) },
> -{ 2, Context.getSizeType() },
> -  };
> -
> -  for (const auto &AT : ArgumentTypes) {
> -const Expr *Arg = Call->getArg(AT.ArgNo)->IgnoreParens();
> -if (Arg->getType().getCanonicalType() == AT.Type.getCanonicalType())
> -  continue;
> -Diag(Arg->getLocStart(), diag::err_typecheck_convert_incompatible)
> -  << Arg->getType() << AT.Type << 1 /* different class */
> -  << 0 /* qualifier difference */ << 3 /* parameter mismatch */
> -  << AT.ArgNo + 1 << Arg->getType() << AT.Type;
> -  }
> +  // __va_start on Windows does not validate the parameter qualifiers
> +
> +  const Expr *Arg1 = Call->getArg(1)->IgnoreParens();
> +  const Type *Arg1Ty = Arg1->getType().getCanonicalType().getTypePtr();
> +
> +  const Expr *Arg2 = Call->getArg(2)->IgnoreParens();
> +  const Type *Arg2Ty = Arg2->getType().getCanonicalType().getTypePtr();
> +
> +  const QualType &ConstCharPtrTy =
> +  Context.getPointerType(Context.CharTy.withConst());
> +  if (!Arg1Ty->isPointerType() ||
> +  Arg1Ty->getPointeeType().withoutLocalFastQualifiers() !=
> Context.CharTy)
> +Diag(Arg1->getLocStart(), diag::err_typecheck_convert_incompatible)
> +<< Arg1->getType() << ConstCharPtrTy
> +<< 1 /* different class */
> +<< 0 /* qualifier difference */
> +<< 3 /* parameter mismatch */
> +<< 2 << Arg1->getType() << ConstCharPtrTy;
> +
> +  const QualType SizeTy = Context.getSizeType();
> +  if (Arg2Ty->getCanonicalTypeInternal().withoutLocalFastQualifiers() !=
> SizeTy)
> +Diag(Arg2->getLocStart(), diag::err_typecheck_convert_incompatible)
> +<< Arg2->getType() << SizeTy
> +<< 1 /* different class */
> +<< 0 /* qualifier difference */
> +<< 3 /* parameter mismatch */
> +<< 3 << Arg2->getType() << SizeTy;
>
>return false;
>  }
>
> Modified: cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/microsoft-varargs.cpp?rev=314226&r1=314225&r2=314226&view=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/microsoft-varargs.cpp (original)
> +++ cfe/trunk/test/SemaCXX/microsoft-varargs.cpp Tue Sep 26 10:44:10 2017
> @@ -20,3 +20,8 @@ int builtin(int i, ...) {
>return __builtin_va_arg(ap, int);
>  }
>
> +void test___va_start_ignore_const(const char *format, ...) {
> +  va_list args;
> +  ((void)(__va_start(&args, (&const_cast(reinterpret_cast volatile char &>(format))), ((sizeof(format) + 4 - 1) & ~(4 - 1)),
> (&const_cast(reinterpret_cast(format));
> +}
> +
>
>
> ___
> 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


r314229 - [Sema] Corrected the warn-on-throw-from-noexcept behavior to include nothrow

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 11:20:39 2017
New Revision: 314229

URL: http://llvm.org/viewvc/llvm-project?rev=314229&view=rev
Log:
[Sema] Corrected the warn-on-throw-from-noexcept behavior to include nothrow

Discovered that 'nothrow' (which is supposed to be an alias for noexcept)
was not warning with a throw inside of it. This patch corrects the behavior
previously created to add 'nothrow' to this list.

Differential Revision: https://reviews.llvm.org/D38203

Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=314229&r1=314228&r2=314229&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Sep 26 11:20:39 2017
@@ -426,7 +426,7 @@ static void checkThrowInNonThrowingFunc(
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs();
-  if (FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()) || FD->hasAttr())
 return true;
   return false;
 }

Modified: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp?rev=314229&r1=314228&r2=314229&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp Tue Sep 26 11:20:39 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -std=c++11
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -fdeclspec -std=c++11
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
@@ -14,6 +14,15 @@ struct R_ShouldDiag : A_ShouldDiag {
   ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing 
exception specification}}
 throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
   }
+  __attribute__((nothrow)) R_ShouldDiag() {// expected-note {{function 
declared non-throwing here}}
+throw 1;// expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __attribute__((nothrow)) SomeThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __declspec(nothrow) SomeDeclspecThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
 };
 
 struct M_ShouldNotDiag {


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


r314231 - Resolve a defect in C++17 copy omission.

2017-09-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep 26 11:37:55 2017
New Revision: 314231

URL: http://llvm.org/viewvc/llvm-project?rev=314231&view=rev
Log:
Resolve a defect in C++17 copy omission.

When selecting constructors for initializing an object of type T from a single
expression of class type U, also consider conversion functions of U that
convert to T (rather than modeling such conversions as calling a conversion
function and then calling a constructor).

This approach is proposed as the resolution for the defect, and is also already
implemented by GCC.

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=314231&r1=314230&r2=314231&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Tue Sep 26 11:37:55 2017
@@ -726,11 +726,20 @@ namespace clang {
 enum CandidateSetKind {
   /// Normal lookup.
   CSK_Normal,
-  /// Lookup for candidates for a call using operator syntax. Candidates
-  /// that have no parameters of class type will be skipped unless there
-  /// is a parameter of (reference to) enum type and the corresponding
-  /// argument is of the same enum type.
-  CSK_Operator
+  /// C++ [over.match.oper]:
+  /// Lookup of operator function candidates in a call using operator
+  /// syntax. Candidates that have no parameters of class type will be
+  /// skipped unless there is a parameter of (reference to) enum type and
+  /// the corresponding argument is of the same enum type.
+  CSK_Operator,
+  /// C++ [over.match.copy]:
+  /// Copy-initialization of an object of class type by user-defined
+  /// conversion.
+  CSK_InitByUserDefinedConversion,
+  /// C++ [over.match.ctor], [over.match.list]
+  /// Initialization of an object of class type by constructor,
+  /// using either a parenthesized or braced list of arguments.
+  CSK_InitByConstructor,
 };
 
   private:
@@ -795,7 +804,7 @@ namespace clang {
 }
 
 /// \brief Clear out all of the candidates.
-void clear();
+void clear(CandidateSetKind CSK);
 
 typedef SmallVectorImpl::iterator iterator;
 iterator begin() { return Candidates.begin(); }
@@ -835,8 +844,7 @@ namespace clang {
 
 /// Find the best viable function on this overload set, if it exists.
 OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc,
- OverloadCandidateSet::iterator& Best,
- bool UserDefinedConversion = false);
+ OverloadCandidateSet::iterator& Best);
 
 void NoteCandidates(Sema &S,
 OverloadCandidateDisplayKind OCD,
@@ -848,10 +856,10 @@ namespace clang {
   };
 
   bool isBetterOverloadCandidate(Sema &S,
- const OverloadCandidate& Cand1,
- const OverloadCandidate& Cand2,
+ const OverloadCandidate &Cand1,
+ const OverloadCandidate &Cand2,
  SourceLocation Loc,
- bool UserDefinedConversion = false);
+ OverloadCandidateSet::CandidateSetKind Kind);
 
   struct ConstructorInfo {
 DeclAccessPair FoundDecl;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=314231&r1=314230&r2=314231&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Sep 26 11:37:55 2017
@@ -2742,13 +2742,15 @@ public:
   CXXRecordDecl *ActingContext,
   Expr *From, QualType ToType,
   OverloadCandidateSet& CandidateSet,
-  bool AllowObjCConversionOnExplicit);
+  bool AllowObjCConversionOnExplicit,
+  bool AllowResultConversion = true);
   void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
   DeclAccessPair FoundDecl,
   CXXRecordDecl *ActingContext,
   Expr *From, QualType ToType,
   OverloadCandidateSet &CandidateSet,
-  bool AllowObjCConversionOnExplicit);
+   

r314232 - Delete trailing whitespace.

2017-09-26 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Sep 26 11:38:56 2017
New Revision: 314232

URL: http://llvm.org/viewvc/llvm-project?rev=314232&view=rev
Log:
Delete trailing whitespace.

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=314232&r1=314231&r2=314232&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue Sep 26 11:38:56 2017
@@ -1023,7 +1023,7 @@ Token *Preprocessor::cacheMacroExpandedT
 
   size_t newIndex = MacroExpandedTokens.size();
   bool cacheNeedsToGrow = tokens.size() >
-  
MacroExpandedTokens.capacity()-MacroExpandedTokens.size(); 
+  
MacroExpandedTokens.capacity()-MacroExpandedTokens.size();
   MacroExpandedTokens.append(tokens.begin(), tokens.end());
 
   if (cacheNeedsToGrow) {


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


Re: r314226 - Sema: Windows/ARM __va_start is not const correct

2017-09-26 Thread Saleem Abdulrasool via cfe-commits
On Tue, Sep 26, 2017 at 11:10 AM, David Majnemer 
wrote:

> Shouldn't you only loosen the check for things targeting the Windows SDK?
> GNU platforms shouldn't need this.
>

That code path only actually happens for MS mode.  `__va_start` is marked
as `ALL_MS_LANGUAGES`.  I suppoes that it would be better to rename the
function to `SemaBuiltinVAStartARMMicrosoft`.  Actually, I like this much
better, I'll rename it.


> On Tue, Sep 26, 2017 at 10:44 AM, Saleem Abdulrasool via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: compnerd
>> Date: Tue Sep 26 10:44:10 2017
>> New Revision: 314226
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=314226&view=rev
>> Log:
>> Sema: Windows/ARM __va_start is not const correct
>>
>> The `__va_start` intrinsic for Windows ARM does not account for const
>> correctness when performing a check.  All local qualifiers are ignored
>> when validating the invocation.  This was exposed by building the swift
>> stdlib against the Windows 10586 SDK for ARM.  Simply expand out the
>> check for the two parameters and ignore the qualifiers for the check.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaC
>> hecking.cpp?rev=314226&r1=314225&r2=314226&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Sep 26 10:44:10 2017
>> @@ -3943,23 +3943,33 @@ bool Sema::SemaBuiltinVAStartARM(CallExp
>>if (checkVAStartIsInVariadicFunction(*this, Func))
>>  return true;
>>
>> -  const struct {
>> -unsigned ArgNo;
>> -QualType Type;
>> -  } ArgumentTypes[] = {
>> -{ 1, Context.getPointerType(Context.CharTy.withConst()) },
>> -{ 2, Context.getSizeType() },
>> -  };
>> -
>> -  for (const auto &AT : ArgumentTypes) {
>> -const Expr *Arg = Call->getArg(AT.ArgNo)->IgnoreParens();
>> -if (Arg->getType().getCanonicalType() == AT.Type.getCanonicalType())
>> -  continue;
>> -Diag(Arg->getLocStart(), diag::err_typecheck_convert_incompatible)
>> -  << Arg->getType() << AT.Type << 1 /* different class */
>> -  << 0 /* qualifier difference */ << 3 /* parameter mismatch */
>> -  << AT.ArgNo + 1 << Arg->getType() << AT.Type;
>> -  }
>> +  // __va_start on Windows does not validate the parameter qualifiers
>> +
>> +  const Expr *Arg1 = Call->getArg(1)->IgnoreParens();
>> +  const Type *Arg1Ty = Arg1->getType().getCanonicalType().getTypePtr();
>> +
>> +  const Expr *Arg2 = Call->getArg(2)->IgnoreParens();
>> +  const Type *Arg2Ty = Arg2->getType().getCanonicalType().getTypePtr();
>> +
>> +  const QualType &ConstCharPtrTy =
>> +  Context.getPointerType(Context.CharTy.withConst());
>> +  if (!Arg1Ty->isPointerType() ||
>> +  Arg1Ty->getPointeeType().withoutLocalFastQualifiers() !=
>> Context.CharTy)
>> +Diag(Arg1->getLocStart(), diag::err_typecheck_convert_incompatible)
>> +<< Arg1->getType() << ConstCharPtrTy
>> +<< 1 /* different class */
>> +<< 0 /* qualifier difference */
>> +<< 3 /* parameter mismatch */
>> +<< 2 << Arg1->getType() << ConstCharPtrTy;
>> +
>> +  const QualType SizeTy = Context.getSizeType();
>> +  if (Arg2Ty->getCanonicalTypeInternal().withoutLocalFastQualifiers()
>> != SizeTy)
>> +Diag(Arg2->getLocStart(), diag::err_typecheck_convert_incompatible)
>> +<< Arg2->getType() << SizeTy
>> +<< 1 /* different class */
>> +<< 0 /* qualifier difference */
>> +<< 3 /* parameter mismatch */
>> +<< 3 << Arg2->getType() << SizeTy;
>>
>>return false;
>>  }
>>
>> Modified: cfe/trunk/test/SemaCXX/microsoft-varargs.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
>> microsoft-varargs.cpp?rev=314226&r1=314225&r2=314226&view=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaCXX/microsoft-varargs.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/microsoft-varargs.cpp Tue Sep 26 10:44:10 2017
>> @@ -20,3 +20,8 @@ int builtin(int i, ...) {
>>return __builtin_va_arg(ap, int);
>>  }
>>
>> +void test___va_start_ignore_const(const char *format, ...) {
>> +  va_list args;
>> +  ((void)(__va_start(&args, (&const_cast(reinterpret_cast> volatile char &>(format))), ((sizeof(format) + 4 - 1) & ~(4 - 1)),
>> (&const_cast(reinterpret_cast(format));
>> +}
>> +
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314235 - Allow IUnknown/IInterface types to come from extern C++

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 11:55:16 2017
New Revision: 314235

URL: http://llvm.org/viewvc/llvm-project?rev=314235&view=rev
Log:
Allow IUnknown/IInterface types to come from extern C++ 

It was brought up in response to my last implementation for
this struct-as-interface features that at least 1 header in
the MS SDK uses "extern C++" around an IUnknown declaration.

The previous implementation demanded that this type exist
in the TranslationUnit DeclContext.  This small change simply
also allows in the situation where we're extern "C++".

Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaCXX/ms-iunknown.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=314235&r1=314234&r2=314235&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Sep 26 11:55:16 2017
@@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() co
 
   // Check "Special" types.
   const auto *Uuid = getAttr();
-  if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() &&
+  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
+ getDeclContext()->isExternCXXContext()) &&
   ((getName() == "IUnknown" &&
 Uuid->getGuid() == "---C000-0046") ||
(getName() == "IDispatch" &&

Modified: cfe/trunk/test/SemaCXX/ms-iunknown.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-iunknown.cpp?rev=314235&r1=314234&r2=314235&view=diff
==
--- cfe/trunk/test/SemaCXX/ms-iunknown.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-iunknown.cpp Tue Sep 26 11:55:16 2017
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
 
-struct __declspec(uuid("---C000-0046")) IUnknown {
+extern "C++" struct __declspec(uuid("---C000-0046")) 
IUnknown {
   void foo();
 };
 struct IPropertyPageBase : public IUnknown {};


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


Re: r314235 - Allow IUnknown/IInterface types to come from extern C++

2017-09-26 Thread Friedman, Eli via cfe-commits

On 9/26/2017 11:55 AM, Erich Keane via cfe-commits wrote:

Author: erichkeane
Date: Tue Sep 26 11:55:16 2017
New Revision: 314235

URL: http://llvm.org/viewvc/llvm-project?rev=314235&view=rev
Log:
Allow IUnknown/IInterface types to come from extern C++

It was brought up in response to my last implementation for
this struct-as-interface features that at least 1 header in
the MS SDK uses "extern C++" around an IUnknown declaration.

The previous implementation demanded that this type exist
in the TranslationUnit DeclContext.  This small change simply
also allows in the situation where we're extern "C++".

Modified:
 cfe/trunk/lib/AST/DeclCXX.cpp
 cfe/trunk/test/SemaCXX/ms-iunknown.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=314235&r1=314234&r2=314235&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Sep 26 11:55:16 2017
@@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() co
  
// Check "Special" types.

const auto *Uuid = getAttr();
-  if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() &&
+  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
+ getDeclContext()->isExternCXXContext()) &&


Do you need to check that the "extern C++" is actually a direct child of 
the translation unit?  Consider, e.g. `namespace X { extern "C++"`...


-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


r314236 - Basic: support Preserve{Most,All} CC on Windows

2017-09-26 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Sep 26 12:26:01 2017
New Revision: 314236

URL: http://llvm.org/viewvc/llvm-project?rev=314236&view=rev
Log:
Basic: support Preserve{Most,All} CC on Windows

Add support for the `preserve_mostcc` and `preserve_allcc` on Windows
x86_64 and AArch64.  This is used by Swift.

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/test/CodeGen/preserve-call-conv.c
cfe/trunk/test/Sema/preserve-call-conv.c

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=314236&r1=314235&r2=314236&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Tue Sep 26 12:26:01 2017
@@ -452,6 +452,8 @@ WindowsARM64TargetInfo::checkCallingConv
 return CCCR_Ignore;
   case CC_C:
   case CC_OpenCLKernel:
+  case CC_PreserveMost:
+  case CC_PreserveAll:
   case CC_Win64:
 return CCCR_OK;
   default:

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=314236&r1=314235&r2=314236&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Tue Sep 26 12:26:01 2017
@@ -916,6 +916,8 @@ public:
 case CC_C:
 case CC_X86VectorCall:
 case CC_IntelOclBicc:
+case CC_PreserveMost:
+case CC_PreserveAll:
 case CC_X86_64SysV:
 case CC_Swift:
 case CC_X86RegCall:

Modified: cfe/trunk/test/CodeGen/preserve-call-conv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/preserve-call-conv.c?rev=314236&r1=314235&r2=314236&view=diff
==
--- cfe/trunk/test/CodeGen/preserve-call-conv.c (original)
+++ cfe/trunk/test/CodeGen/preserve-call-conv.c Tue Sep 26 12:26:01 2017
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm < %s | FileCheck 
%s
 // RUN: %clang_cc1 -triple arm64-unknown-unknown -emit-llvm < %s | FileCheck %s
 
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -emit-llvm %s -o - | 
FileCheck %s
+
 // Check that the preserve_most calling convention attribute at the source 
level
 // is lowered to the corresponding calling convention attrribute at the LLVM IR
 // level.

Modified: cfe/trunk/test/Sema/preserve-call-conv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/preserve-call-conv.c?rev=314236&r1=314235&r2=314236&view=diff
==
--- cfe/trunk/test/Sema/preserve-call-conv.c (original)
+++ cfe/trunk/test/Sema/preserve-call-conv.c Tue Sep 26 12:26:01 2017
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify
 // RUN: %clang_cc1 %s -fsyntax-only -triple arm64-unknown-unknown -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-windows-msvc -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple aarch64-unknown-windows-msvc 
-verify
+
 typedef void typedef_fun_t(int);
 
 void __attribute__((preserve_most)) foo(void *ptr) {


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


RE: r314235 - Allow IUnknown/IInterface types to come from extern C++

2017-09-26 Thread Keane, Erich via cfe-commits
Ah! Sorry, I didn't realize that isExternCXXContext actually searched the 
entire search-set!  Followup patch coming  Thanks for the heads up!

-Original Message-
From: Friedman, Eli [mailto:efrie...@codeaurora.org] 
Sent: Tuesday, September 26, 2017 12:06 PM
To: Keane, Erich ; cfe-commits@lists.llvm.org
Subject: Re: r314235 - Allow IUnknown/IInterface types to come from extern C++

On 9/26/2017 11:55 AM, Erich Keane via cfe-commits wrote:
> Author: erichkeane
> Date: Tue Sep 26 11:55:16 2017
> New Revision: 314235
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314235&view=rev
> Log:
> Allow IUnknown/IInterface types to come from extern C++
>
> It was brought up in response to my last implementation for this 
> struct-as-interface features that at least 1 header in the MS SDK uses 
> "extern C++" around an IUnknown declaration.
>
> The previous implementation demanded that this type exist in the 
> TranslationUnit DeclContext.  This small change simply also allows in 
> the situation where we're extern "C++".
>
> Modified:
>  cfe/trunk/lib/AST/DeclCXX.cpp
>  cfe/trunk/test/SemaCXX/ms-iunknown.cpp
>
> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=
> 314235&r1=314234&r2=314235&view=diff
> ==
> 
> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
> +++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Sep 26 11:55:16 2017
> @@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() co
>   
> // Check "Special" types.
> const auto *Uuid = getAttr();
> -  if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() &&
> +  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
> + getDeclContext()->isExternCXXContext()) 
> + &&

Do you need to check that the "extern C++" is actually a direct child of the 
translation unit?  Consider, e.g. `namespace X { extern "C++"`...

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


r314241 - Sema: rename SemaBuiltinVAStart to SemaBuiltinVAStartMicrosoft

2017-09-26 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Sep 26 13:12:04 2017
New Revision: 314241

URL: http://llvm.org/viewvc/llvm-project?rev=314241&view=rev
Log:
Sema: rename SemaBuiltinVAStart to SemaBuiltinVAStartMicrosoft

This function is used to perform semantic analysis on Microsoft style
`__va_start`.  Rename it to make this more explicit.  `__va_start` is
marked as `ALL_MS_LANGUAGES`, and requires Microsoft compatibility.
Other GNU targets will use `__builtin_va_start` instead.  NFC.

Addresses post-commit review comments from David Majnemer.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=314241&r1=314240&r2=314241&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Sep 26 13:12:04 2017
@@ -10264,7 +10264,7 @@ private:
   bool CheckPPCBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
 
   bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
-  bool SemaBuiltinVAStartARM(CallExpr *Call);
+  bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call);
   bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
   bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
   bool SemaBuiltinVSX(CallExpr *TheCall);

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=314241&r1=314240&r2=314241&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Sep 26 13:12:04 2017
@@ -833,7 +833,7 @@ Sema::CheckBuiltinFunctionCall(FunctionD
 switch (Context.getTargetInfo().getTriple().getArch()) {
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
-  if (SemaBuiltinVAStartARM(TheCall))
+  if (SemaBuiltinVAStartARMMicrosoft(TheCall))
 return ExprError();
   break;
 default:
@@ -3924,7 +3924,7 @@ bool Sema::SemaBuiltinVAStart(unsigned B
   return false;
 }
 
-bool Sema::SemaBuiltinVAStartARM(CallExpr *Call) {
+bool Sema::SemaBuiltinVAStartARMMicrosoft(CallExpr *Call) {
   // void __va_start(va_list *ap, const char *named_addr, size_t slot_size,
   // const char *named_addr);
 


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


r314246 - Fix uninitialized member found by msan build bot.

2017-09-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep 26 14:33:43 2017
New Revision: 314246

URL: http://llvm.org/viewvc/llvm-project?rev=314246&view=rev
Log:
Fix uninitialized member found by msan build bot.

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

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=314246&r1=314245&r2=314246&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Sep 26 14:33:43 2017
@@ -10271,7 +10271,7 @@ struct CompareOverloadCandidatesForDispl
   CompareOverloadCandidatesForDisplay(
   Sema &S, SourceLocation Loc, size_t NArgs,
   OverloadCandidateSet::CandidateSetKind CSK)
-  : S(S), NumArgs(NArgs) {}
+  : S(S), NumArgs(NArgs), CSK(CSK) {}
 
   bool operator()(const OverloadCandidate *L,
   const OverloadCandidate *R) {


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


[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-26 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 116631.
dberris added a comment.

- fixup: limit tests to run on supported platforms and oses


https://reviews.llvm.org/D38226

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/XRay/lit.local.cfg
  test/Driver/XRay/xray-shared-noxray.cpp


Index: test/Driver/XRay/xray-shared-noxray.cpp
===
--- /dev/null
+++ test/Driver/XRay/xray-shared-noxray.cpp
@@ -0,0 +1,16 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+//
+// REQUIRES: linux
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif
Index: test/Driver/XRay/lit.local.cfg
===
--- test/Driver/XRay/lit.local.cfg
+++ test/Driver/XRay/lit.local.cfg
@@ -1,2 +1,20 @@
 target_triple_components = config.target_triple.split('-')
 config.available_features.update(target_triple_components)
+
+# Only run the tests in platforms where XRay instrumentation is supported.
+supported_targets = [
+'amd64', 'x86_64', 'x86_64h', 'arm7', 'arm8', 'aarch64', 'arm64',
+'powerpc64le', 'mips', 'mipsel', 'mips64', 'mips64el'
+]
+
+# Only on platforms we support.
+supported_oses = [
+'linux'
+]
+
+triple_set = set(target_triple_components)
+if len(triple_set.intersection(supported_targets)) == 0:
+  config.unsupported = True
+
+if len(triple_set.intersection(supported_oses)) == 0:
+  config.unsupported = True
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -206,13 +206,18 @@
 
 static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
+
   return false;
 }
 


Index: test/Driver/XRay/xray-shared-noxray.cpp
===
--- /dev/null
+++ test/Driver/XRay/xray-shared-noxray.cpp
@@ -0,0 +1,16 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+//
+// REQUIRES: linux
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif
Index: test/Driver/XRay/lit.local.cfg
===
--- test/Driver/XRay/lit.local.cfg
+++ test/Driver/XRay/lit.local.cfg
@@ -1,2 +1,20 @@
 target_triple_components = config.target_triple.split('-')
 config.available_features.update(target_triple_components)
+
+# Only run the tests in platforms where XRay instrumentation is supported.
+supported_targets = [
+'amd64', 'x86_64', 'x86_64h', 'arm7', 'arm8', 'aarch64', 'arm64',
+'powerpc64le', 'mips', 'mipsel', 'mips64', 'mips64el'
+]
+
+# Only on platforms we support.
+supported_oses = [
+'linux'
+]
+
+triple_set = set(target_triple_components)
+if len(triple_set.intersection(supported_targets)) == 0:
+  config.unsupported = True
+
+if len(triple_set.intersection(supported_oses)) == 0:
+  config.unsupported = True
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -206,13 +206,18 @@
 
 static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
+
   return false;
 }
 
__

[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2017-09-26 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

You seem to be only changing the behavior for the "separatable" fields, but I 
suspect you want to change the behavior for the others too. The bitfield would 
be decomposed into shards, separated by the naturally-sized-and-aligned fields. 
Each access only loads its shard. For example, in your test case you have:

  struct S3 {
unsigned long f1:14;
unsigned long f2:18;
unsigned long f3:32;
  };

and you test that, with this option, loading/storing to a3.f3 only access the 
specific 4 bytes composing f3. But if you load f1 or f2, we're still loading 
all 8 bytes, right? I think we should only load/store the lower 4 bytes when we 
access a3.f1 and/or a3.f2.

Otherwise, you can again end up with the narrow-store/wide-load problem for 
nearby fields under a different set of circumstances.




Comment at: include/clang/Driver/Options.td:1032
 
+def fsplit_bitfields : Flag<["-"], "fsplit-bitfields">,
+  Group, Flags<[CC1Option]>,

I'm not opposed to -fsplit-bitfields, but I'd prefer if we find something more 
self-explanatory. It's not really clear what "splitting a bitfield" means. 
Maybe?

  -fsplit-bitfield-accesses
  -fdecomposed-bitfield-accesses
  -fsharded-bitfield-accesses
  -ffine-grained-bitfield-accesses

(I think that I prefer -ffine-grained-bitfield-accesses, although it's the 
longest)



Comment at: include/clang/Driver/Options.td:1034
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enable splitting bitfield with legal width and alignment in 
LLVM.">;
+def fno_split_bitfields : Flag<["-"], "fno-split-bitfields">,

How about?

  Use separate access for bitfields with legal widths and alignments.

I don't think that "in LLVM" is needed here (or we could put "in LLVM" on an 
awful lot of these options).



Comment at: lib/CodeGen/CGExpr.cpp:1679
+/// field has legal integer width, and its bitfield offset is naturally
+/// aligned, it is better to access the bitfield like a separate integer var.
+static bool IsSeparatableBitfield(const CGBitFieldInfo &Info,

var -> variable


Repository:
  rL LLVM

https://reviews.llvm.org/D36562



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


[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

2017-09-26 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.

C11 standard refers to the unsigned counterpart of the type ptrdiff_t 
in the paragraph 7.19.6 where it defines the format specifier %tu.
In Clang (in PrintfFormatString.cpp, lines 508-510) there is a FIXME for this 
case,
in particular, right now Clang doesn't diagnose %tu issues at all, i.e.
it doesn't emit any warnings on the code printf("%tu", 3.14).
In this diff we add a method getUnsignedPointerDiffType for getting the 
corresponding type
similarly to how it's already done in the other analogous cases (size_t, 
ssize_t, ptrdiff_t etc).
The code for printf diagnostics + new tests are supposed to be added by a 
separate diff.


Repository:
  rL LLVM

https://reviews.llvm.org/D38270

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4571,6 +4571,12 @@
   return getFromTargetType(Target->getPtrDiffType(0));
 }
 
+/// getUnsignedPointerDiffType - Return the unique unsigned counterpart of
+// "ptrdiff_t" integer type.
+QualType ASTContext::getUnsignedPointerDiffType() const {
+  return getFromTargetType(Target->getUnsignedPtrDiffType(0));
+}
+
 /// \brief Return the unique type for "pid_t" defined in
 /// . We need this to compute the correct type for vfork().
 QualType ASTContext::getProcessIDType() const {
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -248,6 +248,9 @@
   IntType getPtrDiffType(unsigned AddrSpace) const {
 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
   }
+  IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
+return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
+  }
   IntType getIntPtrType() const { return IntPtrType; }
   IntType getUIntPtrType() const {
 return getCorrespondingUnsignedType(IntPtrType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1489,6 +1489,10 @@
   /// . Pointer - pointer requires this (C99 6.5.6p9).
   QualType getPointerDiffType() const;
 
+  /// \brief Return the unique unsigned counterpart of 
+  /// "ptrdiff_t" integer type.
+  QualType getUnsignedPointerDiffType() const;
+
   /// \brief Return the unique type for "pid_t" defined in
   /// . We need this to compute the correct type for vfork().
   QualType getProcessIDType() const;


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4571,6 +4571,12 @@
   return getFromTargetType(Target->getPtrDiffType(0));
 }
 
+/// getUnsignedPointerDiffType - Return the unique unsigned counterpart of
+// "ptrdiff_t" integer type.
+QualType ASTContext::getUnsignedPointerDiffType() const {
+  return getFromTargetType(Target->getUnsignedPtrDiffType(0));
+}
+
 /// \brief Return the unique type for "pid_t" defined in
 /// . We need this to compute the correct type for vfork().
 QualType ASTContext::getProcessIDType() const {
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -248,6 +248,9 @@
   IntType getPtrDiffType(unsigned AddrSpace) const {
 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
   }
+  IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
+return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
+  }
   IntType getIntPtrType() const { return IntPtrType; }
   IntType getUIntPtrType() const {
 return getCorrespondingUnsignedType(IntPtrType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1489,6 +1489,10 @@
   /// . Pointer - pointer requires this (C99 6.5.6p9).
   QualType getPointerDiffType() const;
 
+  /// \brief Return the unique unsigned counterpart of 
+  /// "ptrdiff_t" integer type.
+  QualType getUnsignedPointerDiffType() const;
+
   /// \brief Return the unique type for "pid_t" defined in
   /// . We need this to compute the correct type for vfork().
   QualType getProcessIDType() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-26 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 116637.
dberris added a comment.
Herald added a subscriber: srhines.

- fixup: use supported target list in test from clang implementation


https://reviews.llvm.org/D38226

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/XRay/lit.local.cfg
  test/Driver/XRay/xray-shared-noxray.cpp


Index: test/Driver/XRay/xray-shared-noxray.cpp
===
--- /dev/null
+++ test/Driver/XRay/xray-shared-noxray.cpp
@@ -0,0 +1,16 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+//
+// REQUIRES: linux
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif
Index: test/Driver/XRay/lit.local.cfg
===
--- test/Driver/XRay/lit.local.cfg
+++ test/Driver/XRay/lit.local.cfg
@@ -1,2 +1,21 @@
 target_triple_components = config.target_triple.split('-')
 config.available_features.update(target_triple_components)
+
+# Only run the tests in platforms where XRay instrumentation is supported.
+supported_targets = [
+'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le',
+'mips', 'mipsel', 'mips64', 'mips64el'
+]
+
+# Only on platforms we support.
+supported_oses = [
+'linux'
+]
+
+triple_set = set(target_triple_components)
+if len(triple_set.intersection(supported_targets)) == 0:
+  config.unsupported = True
+
+# Do not run for 'android' despite being linux.
+if len(triple_set.intersection(supported_oses)) == 0 or 'android' in 
triple_set:
+  config.unsupported = True
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -206,13 +206,18 @@
 
 static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }
+
   return false;
 }
 


Index: test/Driver/XRay/xray-shared-noxray.cpp
===
--- /dev/null
+++ test/Driver/XRay/xray-shared-noxray.cpp
@@ -0,0 +1,16 @@
+// RUN: %clangxx -shared -fPIC -o /dev/null -v -fxray-instrument %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=SHARED
+// RUN: %clangxx -static -o /dev/null -v -fxray-instrument %s 2>&1 -DMAIN | \
+// RUN: FileCheck %s --check-prefix=STATIC
+// RUN: %clangxx -static -fPIE -o /dev/null -v -fxray-instrument %s 2>&1 \
+// RUN: -DMAIN | FileCheck %s --check-prefix=STATIC
+//
+// SHARED-NOT: {{clang_rt\.xray-}}
+// STATIC: {{clang_rt\.xray-}}
+//
+// REQUIRES: linux
+int foo() { return 42; }
+
+#ifdef MAIN
+int main() { return foo(); }
+#endif
Index: test/Driver/XRay/lit.local.cfg
===
--- test/Driver/XRay/lit.local.cfg
+++ test/Driver/XRay/lit.local.cfg
@@ -1,2 +1,21 @@
 target_triple_components = config.target_triple.split('-')
 config.available_features.update(target_triple_components)
+
+# Only run the tests in platforms where XRay instrumentation is supported.
+supported_targets = [
+'amd64', 'x86_64', 'x86_64h', 'arm', 'aarch64', 'arm64', 'powerpc64le',
+'mips', 'mipsel', 'mips64', 'mips64el'
+]
+
+# Only on platforms we support.
+supported_oses = [
+'linux'
+]
+
+triple_set = set(target_triple_components)
+if len(triple_set.intersection(supported_targets)) == 0:
+  config.unsupported = True
+
+# Do not run for 'android' despite being linux.
+if len(triple_set.intersection(supported_oses)) == 0 or 'android' in triple_set:
+  config.unsupported = True
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -206,13 +206,18 @@
 
 static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
+  // Do not add the XRay runtime to shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+return false;
+
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-whole-archive");
 C

[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

2017-09-26 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 116635.
alexshap added a comment.

fix typo


Repository:
  rL LLVM

https://reviews.llvm.org/D38270

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4571,6 +4571,12 @@
   return getFromTargetType(Target->getPtrDiffType(0));
 }
 
+/// getUnsignedPointerDiffType - Return the unique unsigned counterpart of
+/// "ptrdiff_t" integer type.
+QualType ASTContext::getUnsignedPointerDiffType() const {
+  return getFromTargetType(Target->getUnsignedPtrDiffType(0));
+}
+
 /// \brief Return the unique type for "pid_t" defined in
 /// . We need this to compute the correct type for vfork().
 QualType ASTContext::getProcessIDType() const {
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -248,6 +248,9 @@
   IntType getPtrDiffType(unsigned AddrSpace) const {
 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
   }
+  IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
+return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
+  }
   IntType getIntPtrType() const { return IntPtrType; }
   IntType getUIntPtrType() const {
 return getCorrespondingUnsignedType(IntPtrType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1489,6 +1489,10 @@
   /// . Pointer - pointer requires this (C99 6.5.6p9).
   QualType getPointerDiffType() const;
 
+  /// \brief Return the unique unsigned counterpart of 
+  /// "ptrdiff_t" integer type.
+  QualType getUnsignedPointerDiffType() const;
+
   /// \brief Return the unique type for "pid_t" defined in
   /// . We need this to compute the correct type for vfork().
   QualType getProcessIDType() const;


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4571,6 +4571,12 @@
   return getFromTargetType(Target->getPtrDiffType(0));
 }
 
+/// getUnsignedPointerDiffType - Return the unique unsigned counterpart of
+/// "ptrdiff_t" integer type.
+QualType ASTContext::getUnsignedPointerDiffType() const {
+  return getFromTargetType(Target->getUnsignedPtrDiffType(0));
+}
+
 /// \brief Return the unique type for "pid_t" defined in
 /// . We need this to compute the correct type for vfork().
 QualType ASTContext::getProcessIDType() const {
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -248,6 +248,9 @@
   IntType getPtrDiffType(unsigned AddrSpace) const {
 return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
   }
+  IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
+return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
+  }
   IntType getIntPtrType() const { return IntPtrType; }
   IntType getUIntPtrType() const {
 return getCorrespondingUnsignedType(IntPtrType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1489,6 +1489,10 @@
   /// . Pointer - pointer requires this (C99 6.5.6p9).
   QualType getPointerDiffType() const;
 
+  /// \brief Return the unique unsigned counterpart of 
+  /// "ptrdiff_t" integer type.
+  QualType getUnsignedPointerDiffType() const;
+
   /// \brief Return the unique type for "pid_t" defined in
   /// . We need this to compute the correct type for vfork().
   QualType getProcessIDType() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38191: [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-26 Thread Artem Belevich via Phabricator via cfe-commits
tra reopened this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/trunk/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp:716
   case Intrinsic::nvvm_texsurf_handle_internal:
 SelectTexSurfHandle(N);
+  case Intrinsic::nvvm_match_all_sync_i32p:

I've unintentionally killed `return true;` here and that's what broke the 
texture tests. I'm not sure yet why my local tests worked.


https://reviews.llvm.org/D38191



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


[PATCH] D38249: [libunwind] Skip building unused parts when targeting SJLJ

2017-09-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added inline comments.
This revision is now accepted and ready to land.



Comment at: src/libunwind.cpp:27
 
+#ifndef __USING_SJLJ_EXCEPTIONS__
 #include "AddressSpace.hpp"

I would prefer that you used:

#if !defined(__USING_SJLJ_EXCEPTIONS__)


https://reviews.llvm.org/D38249



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


[PATCH] D38250: [libunwind] Implement the Get/SetTopOfFunctionStack functions via a __thread TLS variable

2017-09-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added a comment.
This revision now requires changes to proceed.

I have a complete implementation for this which is known to work on Windows at 
least.  The only thing that `__thread` requires is a working linker (which does 
not include binutils -- I do have a local patch to make that work though).  Are 
these two the only ones that are missing?  At the very least, the 
implementation of `SetTopOfFunctionStack` is incorrect.


https://reviews.llvm.org/D38250



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


[PATCH] D37976: [docs][refactor] add refactoring engine design documentation

2017-09-26 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lgtm.

Thanks for the documentation! Now we just need to try to keep it up-to-date ;)




Comment at: docs/RefactoringEngine.rst:33
+operations (rules). These rules are grouped under a common umbrella - a single
+``clang-refactor`` subcommand. In addition to rules, the refactoring action
+provides the action's command name and description to ``clang-refactor``.

s/subcommand/command/ ?



Comment at: docs/RefactoringEngine.rst:141
+```
+RefactoringActionRules Rule;
+Rules.push_back(

Var name s/Rule/Rules/ ?


Repository:
  rL LLVM

https://reviews.llvm.org/D37976



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


[PATCH] D37681: [refactor] Simplify the interface and remove some template magic

2017-09-26 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

@klimek Have you got a chance to take a look?


Repository:
  rL LLVM

https://reviews.llvm.org/D37681



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


[PATCH] D38249: [libunwind] Skip building unused parts when targeting SJLJ

2017-09-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo closed this revision.
mstorsjo marked an inline comment as done.
mstorsjo added a comment.

Committed in SVN r314197.


https://reviews.llvm.org/D38249



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


[PATCH] D38247: [libunwind] Correct data types in the _Unwind_FunctionContext struct

2017-09-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo closed this revision.
mstorsjo added a comment.

Committed in SVN r314196.


https://reviews.llvm.org/D38247



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


[PATCH] D38250: [libunwind] Implement the Get/SetTopOfFunctionStack functions via a __thread TLS variable

2017-09-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38250#880871, @compnerd wrote:

> I have a complete implementation for this which is known to work on Windows 
> at least.


Patches for libunwind, or standalone? In any case, please do share if you think 
it's relevant.

> The only thing that `__thread` requires is a working linker (which does not 
> include binutils -- I do have a local patch to make that work though).

Ok, thanks for clarifying. (If I read wikipedia right, it requires Vista if 
built into a DLL that isn't linked to by an executable but loaded via 
LoadLibrary though.)

> Are these two the only ones that are missing?

As far as I've seen in my tests, these are the only ones missing yes. Most of 
the rest of `Unwind_AppleExtras.cpp` contains things not relating to SJLJ.

> At the very least, the implementation of `SetTopOfFunctionStack` is incorrect.

In which way? My implementation does pretty much exactly the same as the apple 
version of `SetTopOfFunctionStack`, but using a `__thread` variable instead of 
`_pthread_setspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key, fc);`.


https://reviews.llvm.org/D38250



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


[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Any thoughts on this?


https://reviews.llvm.org/D37904



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


[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

Thanks for the changes. LGTM.


https://reviews.llvm.org/D35743



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


[PATCH] D38277: [compiler-rt}[CMake] Fix configuration on PowerPC with sanitizers

2017-09-26 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Herald added subscribers: mgorny, dberris, nemanjai.

TEST_BIG_ENDIAN() performs compile tests that will fail with
-nodefaultlibs when building under LLVM_USE_SANITIZER.


https://reviews.llvm.org/D38277

Files:
  cmake/base-config-ix.cmake


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -148,7 +148,14 @@
 endif()
   endif()
 elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+  # Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration
+  # will fail with this option when building with a sanitizer.
+  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
+  # Undo the change.
+  set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
+
   if(HOST_IS_BIG_ENDIAN)
 test_target_arch(powerpc64 "" "-m64")
   else()


Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -148,7 +148,14 @@
 endif()
   endif()
 elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
+  # Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration
+  # will fail with this option when building with a sanitizer.
+  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
   TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
+  # Undo the change.
+  set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
+
   if(HOST_IS_BIG_ENDIAN)
 test_target_arch(powerpc64 "" "-m64")
   else()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38243: [clang-format] Add ext/ to google include categories

2017-09-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D38243



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-09-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 116662.
baloghadamsoftware added a comment.

If both sides have concrete integers, they must be in range [min/4..max/4], if 
only one, it must be in range [min/2..max/2].


https://reviews.llvm.org/D35109

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/svalbuilder-rearrange-comparisons.c

Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- /dev/null
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -0,0 +1,163 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_dump(int x);
+void clang_analyzer_eval(int x);
+void clang_analyzer_printState();
+
+int f();
+
+void compare_different_symbol() {
+  int x = f(), y = f();
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 0}}
+}
+
+void compare_different_symbol_plus_left_int() {
+  int x = f()+1, y = f();
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}}
+}
+
+void compare_different_symbol_minus_left_int() {
+  int x = f()-1, y = f();
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$5{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}}
+}
+
+void compare_different_symbol_plus_right_int() {
+  int x = f(), y = f()+2;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 2}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 2}}
+}
+
+void compare_different_symbol_minus_right_int() {
+  int x = f(), y = f()-2;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 2}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 2}}
+}
+
+void compare_different_symbol_plus_left_plus_right_int() {
+  int x = f()+2, y = f()+1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 1}}
+}
+
+void compare_different_symbol_plus_left_minus_right_int() {
+  int x = f()+2, y = f()-1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$5{int}) - (conj_$2{int})) == 3}}
+}
+
+void compare_different_symbol_minus_left_plus_right_int() {
+  int x = f()-2, y = f()+1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) + 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 3}}
+}
+
+void compare_different_symbol_minus_left_minus_right_int() {
+  int x = f()-2, y = f()-1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$5{int}) - 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$5{int})) == 1}}
+}
+
+void compare_same_symbol() {
+  int x = f(), y = x;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{1 S32b}}
+}
+
+void compare_same_symbol_plus_left_int() {
+  int x = f(), y = x;
+  ++x;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{0 S32b}}
+}
+
+void compare_same_symbol_minus_left_int() {
+  int x = f(), y = x;
+  --x;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{0 S32b}}
+}
+
+void compare_same_symbol_plus_right_int() {
+  int x = f(), y = x+1;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) + 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{0 S32b}}
+}
+
+void compare_same_symbol_minus_right_int() {
+  int x = f(), y = x-1;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$2{int}) - 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{

[PATCH] D37695: [clang-format] Break non-trailing comments, try 2

2017-09-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/ContinuationIndenter.h:270
+  // \c breakProtrudingToken.
+  bool LastBlockCommentWasBroken : 1;
+

We should be *very* careful when adding stuff to ParenState as every extra bit 
of data and every extra comparison can have substantial cost.

Here, specifically:


  - Make this more generic. This currently addresses a very specific use case 
(comment broken), whereas the action is probably always going to be the same 
(enforce break). I think we should call this "NoContinuation" or "NeedsNewline" 
or something.
  - This seems always to only relate to the previous token. So it can be always 
reset when the state is moved further.
  - As this always refers to the previous token, this can probably live in 
LineState instead of ParenState. That way, it has less runtime/space overhead.




https://reviews.llvm.org/D37695



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


[PATCH] D38179: [clang-tidy] Handle unions in modernize-use-equals-default check

2017-09-26 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseEqualsDefaultCheck.cpp:117
+ const CXXMethodDecl *Operator) {
+  const auto *Record = Operator->getParent();
+

aaron.ballman wrote:
> Please don't use `auto` here or elsewhere if the type is not explicitly 
> spelled out.
This was copied from `isCopyAssignmentAndCanBeDefaulted()`.



Comment at: clang-tidy/modernize/UseEqualsDefaultCheck.cpp:119-120
+
+  // A defaulted default constructor of a union with a field with a non trivial
+  // default constructor would be deleted.
+  if (Record->isUnion()) {

aaron.ballman wrote:
> This does not match what's in [class.ctor]p5.
> 
> "X is a union that has a variant member with a non-trivial default 
> constructor and no variant member of X has a default member initializer" -- 
> you aren't checking for the default member initializer.
> 
> also missing for unions: "X is a union and all of its variant members are of 
> const-qualified type (or array thereof)"
> 
> (You should add test cases for these.)
> 
> It might make more sense to implement this as 
> `CXXRecordDecl::defaultedDestructorIsDeleted()`?
Is there any way to call `Sema::ShouldDeleteSpecialMember()` from a clang-tidy 
check?



Comment at: clang-tidy/modernize/UseEqualsDefaultCheck.cpp:127
+
+  if (const RecordType *RecordTy = T->getAs()) {
+CXXRecordDecl *FieldRec = cast(RecordTy->getDecl());

aaron.ballman wrote:
> You can use `auto` here and below.
This was copied from `CXXRecordDecl::addedMember()`.


https://reviews.llvm.org/D38179



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


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 116664.
gtbercea added a comment.

Fix test.


https://reviews.llvm.org/D38040

Files:
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4554,3 +4554,33 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang -DCK30 -std=c++11 -fopenmp -S -emit-llvm 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 \
+// RUN: | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel)
+
+// CK30: {{.*}}void {{.*}}target_maps_parallel_integer{{.*}} {
+
+// CK30: [[GEPOBP:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOBPBIT:%.+]] = bitcast i8** [[GEPOBP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOBPBIT]]
+// CK30: [[GEPOP:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: [[GEPOPBIT:%.+]] = bitcast i8** [[GEPOP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOPBIT]]
+// CK30: [[GEPOBPARG:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOPARG:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: call {{.*}}tgt_target({{.*}}i8** [[GEPOBPARG]], i8** [[GEPOPARG]]
+
+#endif


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4554,3 +4554,33 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 \
+// RUN: | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel)
+
+// CK30: {{.*}}void {{.*}}target_maps_parallel_integer{{.*}} {
+
+// CK30: [[GEPOBP:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOBPBIT:%.+]] = bitcast i8** [[GEPOBP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOBPBIT]]
+// CK30: [[GEPOP:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: [[GEPOPBIT:%.+]] = bitcast i8** [[GEPOP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOPBIT]]
+// CK30: [[GEPOBPARG:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOPARG:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: call {{.*}}tgt_target({{.*}}i8** [[GEPOBPARG]], i8** [[GEPOPARG]]
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38226: [XRay][Driver] Do not link in XRay runtime in shared libs

2017-09-26 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris closed this revision.
dberris added a comment.

Already landed; manually closing.


https://reviews.llvm.org/D38226



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


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-26 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38040



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


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 116671.
gtbercea added a comment.

Add nocudalib flag.


https://reviews.llvm.org/D38040

Files:
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4554,3 +4554,33 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang -DCK30 -std=c++11 -fopenmp -S -emit-llvm 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN: -nocudalib %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel)
+
+// CK30: {{.*}}void {{.*}}target_maps_parallel_integer{{.*}} {
+
+// CK30: [[GEPOBP:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOBPBIT:%.+]] = bitcast i8** [[GEPOBP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOBPBIT]]
+// CK30: [[GEPOP:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: [[GEPOPBIT:%.+]] = bitcast i8** [[GEPOP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOPBIT]]
+// CK30: [[GEPOBPARG:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOPARG:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: call {{.*}}tgt_target({{.*}}i8** [[GEPOBPARG]], i8** [[GEPOPARG]]
+
+#endif


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4554,3 +4554,33 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN: -nocudalib %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel)
+
+// CK30: {{.*}}void {{.*}}target_maps_parallel_integer{{.*}} {
+
+// CK30: [[GEPOBP:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOBPBIT:%.+]] = bitcast i8** [[GEPOBP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOBPBIT]]
+// CK30: [[GEPOP:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: [[GEPOPBIT:%.+]] = bitcast i8** [[GEPOP]]
+// CK30: store i32* %ParamToKernel, i32** [[GEPOPBIT]]
+// CK30: [[GEPOBPARG:%.+]] = getelementptr inbounds {{.*}}offload_baseptrs
+// CK30: [[GEPOPARG:%.+]] = getelementptr inbounds {{.*}}offload_ptrs
+// CK30: call {{.*}}tgt_target({{.*}}i8** [[GEPOBPARG]], i8** [[GEPOPARG]]
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea reopened this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

Open


https://reviews.llvm.org/D38040



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


[PATCH] D38191: [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-26 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 116674.
tra added a comment.

Added missing return. Tests pass now.


https://reviews.llvm.org/D38191

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/match.ll

Index: llvm/test/CodeGen/NVPTX/match.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/match.ll
@@ -0,0 +1,117 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_70 -mattr=+ptx60 | FileCheck %s
+
+declare i32 @llvm.nvvm.match.any.sync.i32(i32, i32)
+declare i64 @llvm.nvvm.match.any.sync.i64(i32, i64)
+
+; CHECK-LABEL: .func{{.*}}match.any.sync.i32
+define i32 @match.any.sync.i32(i32 %mask, i32 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.any.sync.i32_param_0];
+  ; CHECK: ld.param.u32 	[[VALUE:%r[0-9]+]], [match.any.sync.i32_param_1];
+
+  ; CHECK:  match.any.sync.b32  [[V0:%r[0-9]+]], [[VALUE]], [[MASK]];
+  %v0 = call i32 @llvm.nvvm.match.any.sync.i32(i32 %mask, i32 %value)
+  ; CHECK:  match.any.sync.b32  [[V1:%r[0-9]+]], [[VALUE]], 1;
+  %v1 = call i32 @llvm.nvvm.match.any.sync.i32(i32 1, i32 %value)
+  ; CHECK:  match.any.sync.b32  [[V2:%r[0-9]+]], 2, [[MASK]];
+  %v2 = call i32 @llvm.nvvm.match.any.sync.i32(i32 %mask, i32 2)
+  ; CHECK:  match.any.sync.b32  [[V3:%r[0-9]+]], 4, 3;
+  %v3 = call i32 @llvm.nvvm.match.any.sync.i32(i32 3, i32 4)
+  %sum1 = add i32 %v0, %v1
+  %sum2 = add i32 %v2, %v3
+  %sum3 = add i32 %sum1, %sum2
+  ret i32 %sum3;
+}
+
+; CHECK-LABEL: .func{{.*}}match.any.sync.i64
+define i64 @match.any.sync.i64(i32 %mask, i64 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.any.sync.i64_param_0];
+  ; CHECK: ld.param.u64 	[[VALUE:%rd[0-9]+]], [match.any.sync.i64_param_1];
+
+  ; CHECK:  match.any.sync.b64  [[V0:%rd[0-9]+]], [[VALUE]], [[MASK]];
+  %v0 = call i64 @llvm.nvvm.match.any.sync.i64(i32 %mask, i64 %value)
+  ; CHECK:  match.any.sync.b64  [[V1:%rd[0-9]+]], [[VALUE]], 1;
+  %v1 = call i64 @llvm.nvvm.match.any.sync.i64(i32 1, i64 %value)
+  ; CHECK:  match.any.sync.b64  [[V2:%rd[0-9]+]], 2, [[MASK]];
+  %v2 = call i64 @llvm.nvvm.match.any.sync.i64(i32 %mask, i64 2)
+  ; CHECK:  match.any.sync.b64  [[V3:%rd[0-9]+]], 4, 3;
+  %v3 = call i64 @llvm.nvvm.match.any.sync.i64(i32 3, i64 4)
+  %sum1 = add i64 %v0, %v1
+  %sum2 = add i64 %v2, %v3
+  %sum3 = add i64 %sum1, %sum2
+  ret i64 %sum3;
+}
+
+declare {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32, i32)
+declare {i64, i1} @llvm.nvvm.match.all.sync.i64p(i32, i64)
+
+; CHECK-LABEL: .func{{.*}}match.all.sync.i32p(
+define {i32,i1} @match.all.sync.i32p(i32 %mask, i32 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.all.sync.i32p_param_0];
+  ; CHECK: ld.param.u32 	[[VALUE:%r[0-9]+]], [match.all.sync.i32p_param_1];
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, [[VALUE]], [[MASK]];
+  %r1 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 %mask, i32 %value)
+  %v1 = extractvalue {i32, i1} %r1, 0
+  %p1 = extractvalue {i32, i1} %r1, 1
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, 1, [[MASK]];
+  %r2 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 %mask, i32 1)
+  %v2 = extractvalue {i32, i1} %r2, 0
+  %p2 = extractvalue {i32, i1} %r2, 1
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, [[VALUE]], 2;
+  %r3 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 2, i32 %value)
+  %v3 = extractvalue {i32, i1} %r3, 0
+  %p3 = extractvalue {i32, i1} %r3, 1
+
+  ; CHECK:  match.all.sync.b32 {{%r[0-9]+\|%p[0-9]+}}, 4, 3;
+  %r4 = call {i32, i1} @llvm.nvvm.match.all.sync.i32p(i32 3, i32 4)
+  %v4 = extractvalue {i32, i1} %r4, 0
+  %p4 = extractvalue {i32, i1} %r4, 1
+
+  %vsum1 = add i32 %v1, %v2
+  %vsum2 = add i32 %v3, %v4
+  %vsum3 = add i32 %vsum1, %vsum2
+  %psum1 = add i1 %p1, %p2
+  %psum2 = add i1 %p3, %p4
+  %psum3 = add i1 %psum1, %psum2
+  %ret0 = insertvalue {i32, i1} undef, i32 %vsum3, 0
+  %ret1 = insertvalue {i32, i1} %ret0, i1 %psum3, 1
+  ret {i32, i1} %ret1;
+}
+
+; CHECK-LABEL: .func{{.*}}match.all.sync.i64p(
+define {i64,i1} @match.all.sync.i64p(i32 %mask, i64 %value) {
+  ; CHECK: ld.param.u32 	[[MASK:%r[0-9]+]], [match.all.sync.i64p_param_0];
+  ; CHECK: ld.param.u64 	[[VALUE:%rd[0-9]+]], [match.all.sync.i64p_param_1];
+
+  ; CHECK:  match.all.sync.b64 {{%rd[0-9]+\|%p[0-9]+}}, [[VALUE]], [[MASK]];
+  %r1 = call {i64, i1} @llvm.nvvm.match.all.sync.i64p(i32 %mask, i64 %value)
+  %v1 = extractvalue {i64, i1} %r1, 0
+  %p1 = extractvalue {i64, i1} %r1, 1
+
+  ; CHECK:  match.all.sync.b64 {{%rd[0-9]+\|%p[0-9]+}}, 1, [[MASK]];
+  %r2 = call {i64, i1} @llvm.nvvm.match.all.sync.i64p(i32 %mask, i64 1)
+  %v2 = extractvalue {i64, i1} %r2, 0
+  %p2 = 

[PATCH] D37023: [analyzer] Fix bugreporter::getDerefExpr() again.

2017-09-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 116673.
NoQ added a comment.

Add no-crash test cases from https://bugs.llvm.org/show_bug.cgi?id=34373 and 
https://bugs.llvm.org/show_bug.cgi?id=34731 .


https://reviews.llvm.org/D37023

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/null-deref-path-notes.c
  test/Analysis/null-deref-path-notes.cpp
  test/Analysis/null-deref-path-notes.m

Index: test/Analysis/null-deref-path-notes.m
===
--- test/Analysis/null-deref-path-notes.m
+++ test/Analysis/null-deref-path-notes.m
@@ -50,6 +50,23 @@
   *p = 1; // expected-warning{{Dereference of null pointer}} expected-note{{Dereference of null pointer}}
 }
 
+@interface WithArrayPtr
+- (void) useArray;
+@end
+
+@implementation WithArrayPtr {
+@public int *p;
+}
+- (void)useArray {
+  p[1] = 2; // expected-warning{{Array access (via ivar 'p') results in a null pointer dereference}}
+// expected-note@-1{{Array access (via ivar 'p') results in a null pointer dereference}}
+}
+@end
+
+void testWithArrayPtr(WithArrayPtr *w) {
+  w->p = 0; // expected-note{{Null pointer value stored to 'p'}}
+  [w useArray]; // expected-note{{Calling 'useArray'}}
+}
 
 // CHECK:  diagnostics
 // CHECK-NEXT:  
@@ -801,4 +818,227 @@
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:path
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line67
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line67
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line67
+// CHECK-NEXT:  col10
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Null pointer value stored to 'p'
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Null pointer value stored to 'p'
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line67
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line67
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line68
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line68
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line68
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line68
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line68
+// CHECK-NEXT:  col14
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Calling 'useArray'
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Calling 'useArray'
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line60
+// CHECK-NEXT:   col1
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth1
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Entered call from 'testWithArrayPtr'
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Entered call from 'testWithArrayPtr'
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line60
+// CHECK-NEXT:col1
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line60
+// CHECK-NEXT:col1
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEX

[PATCH] D38208: Add support for remembering origins to ExternalASTMerger

2017-09-26 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 116680.
spyffe added a comment.

Updates and small refactors requested by Bruno.


Repository:
  rL LLVM

https://reviews.llvm.org/D38208

Files:
  include/clang/AST/ExternalASTMerger.h
  lib/AST/ExternalASTMerger.cpp
  lib/Sema/SemaType.cpp
  test/Import/extern-c-function/Inputs/F.cpp
  test/Import/extern-c-function/test.cpp
  test/Import/forward-declared-objc-class/Inputs/S1.m
  test/Import/forward-declared-objc-class/Inputs/S2.m
  test/Import/forward-declared-objc-class/Inputs/S3.m
  test/Import/forward-declared-objc-class/test.m
  test/Import/forward-declared-struct/Inputs/S3.c
  test/Import/forward-declared-struct/test.c
  test/Import/local-struct-use-origins/Inputs/Callee.cpp
  test/Import/local-struct-use-origins/test.cpp
  test/Import/local-struct/test.cpp
  test/Import/objc-definitions-in-expression/Inputs/S.m
  test/Import/objc-definitions-in-expression/test.m
  test/Import/struct-and-var/Inputs/S1.cpp
  test/Import/struct-and-var/Inputs/S2.cpp
  test/Import/struct-and-var/test.cpp
  test/Import/template/Inputs/T.cpp
  test/Import/template/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -48,8 +48,12 @@
 
 static llvm::cl::opt
 Direct("direct", llvm::cl::Optional,
- llvm::cl::desc("Use the parsed declarations without indirection"));
+   llvm::cl::desc("Use the parsed declarations without indirection"));
 
+static llvm::cl::opt
+UseOrigins("use-origins", llvm::cl::Optional,
+   llvm::cl::desc("Use DeclContext origin information for more accurate lookups"));  
+
 static llvm::cl::list
 ClangArgs("Xcc", llvm::cl::ZeroOrMore,
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -60,13 +64,11 @@
   llvm::cl::desc("The language to parse (default: c++)"),
   llvm::cl::init("c++"));
 
-static llvm::cl::opt
-DumpAST("dump-ast", llvm::cl::init(false),
-llvm::cl::desc("Dump combined AST"));
+static llvm::cl::opt DumpAST("dump-ast", llvm::cl::init(false),
+   llvm::cl::desc("Dump combined AST"));
 
-static llvm::cl::opt
-DumpIR("dump-ir", llvm::cl::init(false),
-llvm::cl::desc("Dump IR from final parse"));
+static llvm::cl::opt DumpIR("dump-ir", llvm::cl::init(false),
+  llvm::cl::desc("Dump IR from final parse"));
 
 namespace init_convenience {
 class TestDiagnosticConsumer : public DiagnosticConsumer {
@@ -154,8 +156,7 @@
   }
 };
 
-std::unique_ptr
-BuildCompilerInstance() {
+std::unique_ptr BuildCompilerInstance() {
   auto Ins = llvm::make_unique();
   auto DC = llvm::make_unique();
   const bool ShouldOwnClient = true;
@@ -227,29 +228,54 @@
 } // end namespace
 
 namespace {
- 
-void AddExternalSource(
-CompilerInstance &CI,
-llvm::ArrayRef> Imports) {
-  ExternalASTMerger::ImporterEndpoint Target({CI.getASTContext(), CI.getFileManager()});
-  llvm::SmallVector Sources;
-  for (const std::unique_ptr &CI : Imports) {
-Sources.push_back({CI->getASTContext(), CI->getFileManager()});
+
+/// A container for a CompilerInstance (possibly with an ExternalASTMerger
+/// attached to its ASTContext).
+///
+/// Provides an accessor for the DeclContext origins associated with the
+/// ExternalASTMerger (or an empty list of origins if no ExternalASTMerger is
+/// attached).
+///
+/// This is the main unit of parsed source code maintained by clang-import-test.
+struct CIAndOrigins {
+  using OriginMap = clang::ExternalASTMerger::OriginMap;
+  std::unique_ptr CI;
+
+  ASTContext &getASTContext() { return CI->getASTContext(); }
+  FileManager &getFileManager() { return CI->getFileManager(); }
+  const OriginMap &getOriginMap() {
+static const OriginMap EmptyOriginMap;
+if (ExternalASTSource *Source = CI->getASTContext().getExternalSource())
+  return static_cast(Source)->GetOrigins();
+return EmptyOriginMap;
   }
+  DiagnosticConsumer &getDiagnosticClient() {
+return CI->getDiagnosticClient();
+  }
+  CompilerInstance &getCompilerInstance() { return *CI; }
+};
+
+void AddExternalSource(CIAndOrigins &CI,
+   llvm::MutableArrayRef Imports) {
+  ExternalASTMerger::ImporterTarget Target(
+  {CI.getASTContext(), CI.getFileManager()});
+  llvm::SmallVector Sources;
+  for (CIAndOrigins &Import : Imports)
+Sources.push_back(
+{Import.getASTContext(), Import.getFileManager(), Import.getOriginMap()});
   auto ES = llvm::make_unique(Target, Sources);
   CI.getASTContext().setExternalSource(ES.release());
   CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
 }
 
-std::unique_ptr BuildIndirect(std::unique_ptr &CI) {
-  std::unique_ptr IndirectCI =
-  init_convenience::BuildCompilerInstance();
+CIAndOrigins B

[PATCH] D38191: [NVPTX] added match.{any, all}.sync instructions, intrinsics & builtins.

2017-09-26 Thread Artem Belevich via Phabricator via cfe-commits
tra closed this revision.
tra added a comment.

Landed with fix in r314223.


https://reviews.llvm.org/D38191



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


[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-26 Thread András Leitereg via Phabricator via cfe-commits
leanil updated this revision to Diff 116694.
leanil added a comment.

Add more tests and minor fixes.


https://reviews.llvm.org/D38171

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyModule.h
  clang-tidy/cert/CERTTidyModule.cpp
  test/clang-tidy/cert-exp59-cpp.cpp
  test/clang-tidy/warning-check-aliases.cpp

Index: test/clang-tidy/warning-check-aliases.cpp
===
--- /dev/null
+++ test/clang-tidy/warning-check-aliases.cpp
@@ -0,0 +1,21 @@
+// RUN: clang-tidy %s -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy %s -checks='-*,cert-err54-cpp' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s
+// RUN: clang-tidy %s -checks='-*,cert-err54-cpp' -- -Wno-exceptions 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s
+
+class B {};
+class D : public B {};
+
+void f() {
+  try {
+
+  } catch (B &X) {
+
+  } catch (D &Y) {
+  }
+}
+
+//CHECK: :13:12: warning: exception of type 'D &' will be caught by earlier handler [clang-diagnostic-exceptions]
+//CHECK: :11:12: note: for type 'B &'
+
+//CHECK2: :13:12: warning: exception of type 'D &' will be caught by earlier handler [cert-err54-cpp]
+//CHECK2: :11:12: note: for type 'B &'
Index: test/clang-tidy/cert-exp59-cpp.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-exp59-cpp.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-tidy %s -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy %s -checks='-*,cert-exp59-cpp' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s
+// RUN: clang-tidy %s -checks='-*,cert-exp59-cpp' -- -Wno-invalid-offsetof 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s
+
+#include 
+
+struct D {
+virtual void f() {}
+int i;
+};
+
+void f() {
+size_t Off = offsetof(D, i);
+//CHECK: :[[@LINE-1]]:18: warning: offset of on non-POD type 'D' [clang-diagnostic-invalid-offsetof]
+//CHECK2: :[[@LINE-2]]:18: warning: offset of on non-POD type 'D' [cert-exp59-cpp]
+}
Index: clang-tidy/cert/CERTTidyModule.cpp
===
--- clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tidy/cert/CERTTidyModule.cpp
@@ -26,6 +26,7 @@
 #include "StrToNumCheck.h"
 #include "ThrownExceptionTypeCheck.h"
 #include "VariadicFunctionDefCheck.h"
+#include "clang/Sema/SemaDiagnostic.h"
 
 namespace clang {
 namespace tidy {
@@ -73,6 +74,14 @@
 // MSC
 CheckFactories.registerCheck("cert-msc30-c");
   }
+
+  void addWarningCheckAliases(
+  llvm::DenseMap &WarningCheckAliases) override {
+WarningCheckAliases.try_emplace(
+diag::warn_exception_caught_by_earlier_handler, "cert-err54-cpp");
+WarningCheckAliases.try_emplace(
+diag::ext_offsetof_non_pod_type, "cert-exp59-cpp");
+  }
 };
 
 } // namespace cert
Index: clang-tidy/ClangTidyModule.h
===
--- clang-tidy/ClangTidyModule.h
+++ clang-tidy/ClangTidyModule.h
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULE_H
 
 #include "ClangTidy.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 #include 
@@ -89,6 +90,11 @@
   /// belonging to this module.
   virtual void addCheckFactories(ClangTidyCheckFactories &CheckFactories) = 0;
 
+  /// \brief Implement this function in order to register all warning-check
+  /// aliases belonging to this module.
+  virtual void addWarningCheckAliases(
+  llvm::DenseMap &WarningCheckAliases) {}
+
   /// \brief Gets default options for checks defined in this module.
   virtual ClangTidyOptions getModuleOptions();
 };
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -17,6 +17,7 @@
 #include "clang/Tooling/Refactoring.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/Timer.h"
 
@@ -186,6 +187,8 @@
 return CurrentBuildDirectory;
   }
 
+  llvm::DenseMap WarningCheckAliases;
+
 private:
   // Calls setDiagnosticsEngine() and storeError().
   friend class ClangTidyDiagnosticConsumer;
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -374,9 +374,15 @@
 StringRef WarningOption =
 Context.DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(
 Info.getID());
-std::string CheckName = !WarningOption.empty()
- 

[PATCH] D38171: Implement clang-tidy check aliases.

2017-09-26 Thread András Leitereg via Phabricator via cfe-commits
leanil added a comment.

In https://reviews.llvm.org/D38171#880021, @xazax.hun wrote:

> In https://reviews.llvm.org/D38171#878808, @alexfh wrote:
>
> > András, that's definitely an interesting idea. However, it might be 
> > interesting to explore a more principled approach:
> >
> > 1. Make `clang-diagnostic-*` checks first-class citizens and take full 
> > control of all diagnostics, i.e. disable all Clang diagnostics by default, 
> > and enable the ones that correspond to the enabled clang-diagnostic checks.
>
>
> I agree that this is a good idea. I think it could be done in this patch. But 
> to be sure, could you elaborate on what do you mean by first-class citizen?
>
> > 2. Make aliases first-class citizens (there was a proposal as well, but we 
> > didn't arrive to a consensus at that time). That would include the ability 
> > to configure an alias name for any check including clang-diagnostic- and 
> > clang-analyzer- checks.
>
> Do you have a link to the proposal? What do you mean by the ability to 
> configure? As in having a config file or registering aliases in modules like 
> now? If you mean the former, I think that is better addressed in a follow-up 
> patch.


I also think this sounds good, though I'm not quite sure it can be done in this 
patch. Anyway, we should definitely specify what we expect from first-class 
citizen checks. Please correct & extend the list:

- can be enabled or disabled through a unique name
- can have config options
- can have aliases
- inherits ClangTidyCheck

I see the last one as a requirement for handling everything uniformly (without 
workarounds like this patch), but also as a main point where an alias differs 
from a "real" check.


https://reviews.llvm.org/D38171



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-26 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.
Herald added a subscriber: mgorny.

Currently when we do `-fuse-ld=lld` for apple targets this invokes the gnu 
frontend because of the `ld.lld` alias
This creates a new alias for ld64 as `ld64.lld` to avoid this.


Repository:
  rL LLVM

https://reviews.llvm.org/D38290

Files:
  tools/clang/lib/Driver/ToolChain.cpp
  tools/lld/tools/lld/CMakeLists.txt
  tools/lld/tools/lld/lld.cpp


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if(Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if(Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-09-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea reopened this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

Open


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-26 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

I have a patch that does a bunch of updates for testing lld correctly in clang 
and this was a part of it but I didn't want the patch to get too involved so I 
separated this out.
I have seen this issue raised on various forums such as stackoverflow here and 
figured I would just fix it for users.
https://stackoverflow.com/questions/44106329/lld-unknown-argument-arch


Repository:
  rL LLVM

https://reviews.llvm.org/D38290



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


[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)

2017-09-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D37436#871117, @aaron.ballman wrote:

> Updated based on review feedback.
>
> - Rename CAttributes to DoubleSquareBracketAttributes
> - Added Objective-C test cases to demonstrate no regressed behavior (based on 
> a use-case pointed out during review)
> - Fixed regression with GNU-style attributes in enumerations
>
>   I still need to rename the cc1 flag, pending agreement on the name.


Ping -- the last outstanding issue that I'm aware of is the cc1 flag name, do 
you have a preference there, Richard? If not, I'll be going with the verbose 
`-fdouble-square-bracket-attributes`.


https://reviews.llvm.org/D37436



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


[PATCH] D38291: clang-format/java: Unbreak genenrics formatting after r299952.

2017-09-26 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
Herald added a subscriber: klimek.

https://reviews.llvm.org/rL299952 merged '>>>' tokens into a single 
JavaRightLogicalShift token. This broke formatting of generics nested more than 
 two deep, e.g. `Foo>>` because the '>>>' now weren't three '>' for 
parseAngle().

Luckily, just deleting JavaRightLogicalShift fixes things without breaking the 
test added in r299952, so do that.


https://reviews.llvm.org/D38291

Files:
  lib/Format/FormatTokenLexer.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJava.cpp


Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -333,6 +333,11 @@
   verifyFormat("Iterable a;");
 
   verifyFormat("A.doSomething();");
+  verifyFormat("A.>doSomething();");
+  verifyFormat("A.>>doSomething();");
+  verifyFormat("A.>>>doSomething();");
+
+  verifyFormat("OrderedPair>> p = null;");
 
   verifyFormat("@Override\n"
"public Map getAll() {}");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -47,7 +47,7 @@
 if (NonTemplateLess.count(CurrentToken->Previous))
   return false;
 
-const FormatToken &Previous = *CurrentToken->Previous;
+const FormatToken &Previous = *CurrentToken->Previous;  // The '<'.
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
@@ -2323,7 +2323,7 @@
   if (Left.is(TT_TemplateCloser) && Left.MatchingParen &&
   Left.MatchingParen->Previous &&
   Left.MatchingParen->Previous->is(tok::period))
-// A.DoSomething();
+// A.>>DoSomething();
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -96,12 +96,8 @@
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
-static const tok::TokenKind JavaRightLogicalShift[] = {
-tok::greater, tok::greater, tok::greater};
 static const tok::TokenKind JavaRightLogicalShiftAssign[] = {
 tok::greater, tok::greater, tok::greaterequal};
-if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator))
-  return;
 if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator))
   return;
   }


Index: unittests/Format/FormatTestJava.cpp
===
--- unittests/Format/FormatTestJava.cpp
+++ unittests/Format/FormatTestJava.cpp
@@ -333,6 +333,11 @@
   verifyFormat("Iterable a;");
 
   verifyFormat("A.doSomething();");
+  verifyFormat("A.>doSomething();");
+  verifyFormat("A.>>doSomething();");
+  verifyFormat("A.>>>doSomething();");
+
+  verifyFormat("OrderedPair>> p = null;");
 
   verifyFormat("@Override\n"
"public Map getAll() {}");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -47,7 +47,7 @@
 if (NonTemplateLess.count(CurrentToken->Previous))
   return false;
 
-const FormatToken &Previous = *CurrentToken->Previous;
+const FormatToken &Previous = *CurrentToken->Previous;  // The '<'.
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
@@ -2323,7 +2323,7 @@
   if (Left.is(TT_TemplateCloser) && Left.MatchingParen &&
   Left.MatchingParen->Previous &&
   Left.MatchingParen->Previous->is(tok::period))
-// A.DoSomething();
+// A.>>DoSomething();
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -96,12 +96,8 @@
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
-static const tok::TokenKind JavaRightLogicalShift[] = {
-tok::greater, tok::greater, tok::greater};
 static const tok::TokenKind JavaRightLogicalShiftAssign[] = {
 tok::greater, tok::greater, tok::greaterequal};
-if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator))
-  return;
 if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator))
   return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38202: Add Documentation to attribute-nothrow. Additionally, limit to functions.

2017-09-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:2692
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` attribute as an
+equivilent of `noexcept` on function declarations. This attribute informs the

aaron.ballman wrote:
> Should probably add something about `__declspec(nothrow)` as well.
> 
> Are the semantics really identical to `noexcept`? For instance, does 
> `std::terminate()` get called if a function is marked `__declspec(nothrow)` 
> and it throws, or does it simply crash?
I'm unable in GCC to identify any difference between nothrow and noexcept.  It 
DOES do std::terminate in 7.2, and presumably older versions as well.


https://reviews.llvm.org/D38202



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 116704.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Rebase to ToT and clean up logic.


https://reviews.llvm.org/D35082

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/NVPTX.h
  lib/Basic/Targets/SPIR.h
  lib/Basic/Targets/TCE.h
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/blocks-opencl.cl
  test/CodeGenOpenCL/address-spaces-mangling.cl
  test/CodeGenOpenCL/address-spaces.cl
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/atomic-ops.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCL/null_literal.cl

Index: test/SemaOpenCL/null_literal.cl
===
--- test/SemaOpenCL/null_literal.cl
+++ test/SemaOpenCL/null_literal.cl
@@ -1,29 +1,68 @@
 // RUN: %clang_cc1 -verify %s
-// RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -verify %s
 
 #define NULL ((void*)0)
 
 void foo(){
+  global int *g1 = NULL;
+  global int *g2 = (global void *)0;
+  global int *g3 = (constant void *)0; // expected-error{{initializing '__global int *' with an expression of type '__constant void *' changes address space of pointer}}
+  global int *g4 = (local void *)0; // expected-error{{initializing '__global int *' with an expression of type '__local void *' changes address space of pointer}}
+  global int *g5 = (private void *)0; // expected-error{{initializing '__global int *' with an expression of type '__private void *' changes address space of pointer}}
 
-global int* ptr1 = NULL;
+  constant int *c1 = NULL;
+  constant int *c2 = (global void *)0; // expected-error{{initializing '__constant int *' with an expression of type '__global void *' changes address space of pointer}}
+  constant int *c3 = (constant void *)0;
+  constant int *c4 = (local void *)0; // expected-error{{initializing '__constant int *' with an expression of type '__local void *' changes address space of pointer}}
+  constant int *c5 = (private void *)0; // expected-error{{initializing '__constant int *' with an expression of type '__private void *' changes address space of pointer}}
 
-global int* ptr2 = (global void*)0;
+  local int *l1 = NULL;
+  local int *l2 = (global void *)0; // expected-error{{initializing '__local int *' with an expression of type '__global void *' changes address space of pointer}}
+  local int *l3 = (constant void *)0; // expected-error{{initializing '__local int *' with an expression of type '__constant void *' changes address space of pointer}}
+  local int *l4 = (local void *)0;
+  local int *l5 = (private void *)0; // expected-error{{initializing '__local int *' with an expression of type '__private void *' changes address space of pointer}}
 
-constant int* ptr3 = NULL;
+  private int *p1 = NULL;
+  private int *p2 = (global void *)0; // expected-error{{initializing '__private int *' with an expression of type '__global void *' changes address space of pointer}}
+  private int *p3 = (constant void *)0; // expected-error{{initializing '__private int *' with an expression of type '__constant void *' changes address space of pointer}}
+  private int *p4 = (local void *)0; // expected-error{{initializing '__private int *' with an expression of type '__local void *' changes address space of pointer}}
+  private int *p5 = (private void *)0;
 
-constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *' with an expression of type '__global void *' changes address space of pointer}}
+#if __OPENCL_C_VERSION__ >= 200
+  // Assigning a pointer to a pointer to narrower address space causes an error unless there is an valid explicit cast.
+  global int *g6 = (generic void *)0; // expected-error{{initializing '__global int *' with an expression of type '__generic void *' changes address space of pointer}}
+  constant int *c6 = (generic void *)0; // expected-error{{initializing '__constant int *' with an expression of type '__generic void *' changes address space of pointer}}
+  local int *l6 = (generic void *)0; // expected-error{{initializing '__local int *' with an expression of type '__generic void *' changes address space of pointer}}
+  private int *p6 = (generic void *)0; // expected-error{{initializing '__private int *' with an expression of type '__generic void *' changes address space of pointer}}
 
-#ifdef CL20
-// Accept explicitly pointer to generic address space in OpenCL v2.0.
-global int* ptr5 = (generic void*)0;
-#endif
-
-global int* ptr6 = (local void*)0; // expected-error{{initializing '__global int *' with an expression of type

[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/Sema/SemaType.cpp:6974
 
+  if (state.getSema().getLangOpts().OpenCL && !hasOpenCLAddressSpace &&
+  type.getAddressSpace() == LangAS::Default &&

Anastasia wrote:
> I am not very convinced we need to do all this check really... I think since 
> we have to live with this code further and maintain it let's try to simplify 
> it a bit. This can also help us avoid redundant checks. Perhaps we could even 
> move it out in a separate function?
> 
> How about some sort of hierarchical check structure like:
> 
> | |**CL version?** ||
> |<2.0||>=2.0|
> |`private`||**Type?**||
> ||pointer||non-pointer|
> ||`generic`||**Scope?**||
> |||program||function|
> |||`global`||**Qualifiers?**|
> none||static/extern|
> `private`||`global`|
> 
fixed.


https://reviews.llvm.org/D35082



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


[PATCH] D38202: Add Documentation to attribute-nothrow. Additionally, limit to functions.

2017-09-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 116705.
erichkeane added a comment.

Added declspec, fixed does cannot.


https://reviews.llvm.org/D38202

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  test/Misc/pragma-attribute-supported-attributes-list.test


Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -40,6 +40,7 @@
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, 
SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
+// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2727,6 +2727,18 @@
   }];
 }
 
+def NoThrowDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` and Microsoft style
+``__declspec(nothrow)`` attribute as an equivilent of `noexcept` on function
+declarations. This attribute informs the compiler that the annotated function
+does not throw an exception. This prevents exception-unwinding. This attribute
+is particularly useful on functions in the C Standard Library that are
+guaranteed to not throw an exception.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1437,7 +1437,8 @@
 
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoThrowDocs];
 }
 
 def NvWeak : IgnoredAttr {


Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -40,6 +40,7 @@
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
+// CHECK-NEXT: NoThrow (SubjectMatchRule_function)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2727,6 +2727,18 @@
   }];
 }
 
+def NoThrowDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the GNU style ``__attribute__((nothrow))`` and Microsoft style
+``__declspec(nothrow)`` attribute as an equivilent of `noexcept` on function
+declarations. This attribute informs the compiler that the annotated function
+does not throw an exception. This prevents exception-unwinding. This attribute
+is particularly useful on functions in the C Standard Library that are
+guaranteed to not throw an exception.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1437,7 +1437,8 @@
 
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoThrowDocs];
 }
 
 def NvWeak : IgnoredAttr {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29479: Driver: Do not warn about unused -pthread when linking on darwin

2017-09-26 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB closed this revision.
MatzeB added a comment.

This was accepted on the mailinglist and committed in r294065


Repository:
  rL LLVM

https://reviews.llvm.org/D29479



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


[PATCH] D38209: [Sema] Correct nothrow inherited by noexcept

2017-09-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D38209#880559, @aaron.ballman wrote:

> In https://reviews.llvm.org/D38209#880553, @STL_MSFT wrote:
>
> > > do you think `__declspec(nothrow)` calling the terminate handler in Clang 
> > > is a bug?
> >
> > It's certainly a behavior difference with potential performance impact, 
> > although I don't think it can be viewed as a bug, strictly speaking. MSVC 
> > treats `__declspec(nothrow)` as an optimization request, with undefined 
> > behavior if it's violated. Termination is definitely one of the possible 
> > results of undefined behavior.
> >
> > We've recently had to slightly rethink our EH strategy in light of C++17's 
> > addition of noexcept into the type system, and the removal of dynamic 
> > exception specifications (and the change in semantics to throw()). MSVC's 
> > /EHsc makes this extra fun. If you're interested, I can put you in contact 
> > with the compiler dev who recently made those changes.
>
>
> That might be helpful. I'm mostly interested in whether `__declspec(nothrow)` 
> is intended to be part of the type system in the same way `noexcept` 
> specifiers are.
>
> @erichkeane -- can you see whether `__attribute__((nothrow))` is part of the 
> type system as far as GCC is concerned (in C++17 mode, assuming GCC has 
> implemented that functionality already)?


I just did some playing around with godbolt, and it seems that 
attribute-nothrow does NOT modify the mangled name in GCC C++17 mode (when done 
as a template-parameter to a 'call' function), so it seems to me that it is NOT 
part of the type system in this regard.

Interestingly, however, GCC allows the first exampel in the test (Base w/ 
attribute, derrived with noexcept) with or WITHOUT the attribute.  It seems to 
just completely lack this check even in trunk.


https://reviews.llvm.org/D38209



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


[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-26 Thread Paul Robinson via Phabricator via cfe-commits
probinson updated this revision to Diff 116711.
probinson added a comment.

Add a command-line flag to control emitting the template parameter children. 
Default to on for SCE debugger tuning.
I am not super excited about my choice of option name or the help text; 
alternate suggestions welcome.

I would prefer to eliminate the `` from the instance name as well, 
because our debugger reconstructs a name more to its liking from the parameter 
children.  However, IIUC the name with params is used for deduplication in LTO, 
so that is probably not such a good idea. :-)


https://reviews.llvm.org/D14358

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/debug-info-fwd-template-param.cpp
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -495,6 +495,11 @@
 // CHECK-PROFILE-DEBUG: -fdebug-info-for-profiling
 // CHECK-NO-PROFILE-DEBUG-NOT: -fdebug-info-for-profiling
 
+// RUN: %clang -### -S -fdebug-forward-template-params %s 2>&1 | FileCheck -check-prefix=CHECK-FWD-TMPL %s
+// RUN: %clang -### -S -fno-debug-forward-template-params %s 2>&1 | FileCheck -check-prefix=CHECK-NO-FWD-TMPL %s
+// CHECK-FWD-TMPL: -fdebug-forward-template-params
+// CHECK-NO-FWD-TMPL-NOT: -fdebug-forward-template-params
+
 // RUN: %clang -### -S -fallow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-ALLOW-PLACEHOLDERS %s
 // RUN: %clang -### -S -fno-allow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ALLOW-PLACEHOLDERS %s
 // CHECK-ALLOW-PLACEHOLDERS: -fallow-editor-placeholders
Index: test/CodeGenCXX/debug-info-fwd-template-param.cpp
===
--- test/CodeGenCXX/debug-info-fwd-template-param.cpp
+++ test/CodeGenCXX/debug-info-fwd-template-param.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -fdebug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=CHILD %s
+// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited -fno-debug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=NONE %s
+// A forward declaration of a template instantiation should have template
+// parameter children (if we ask for them).
+
+template class A {
+public:
+  A(T val);
+private:
+  T x;
+};
+
+struct B {
+  A *p;
+};
+
+B b;
+
+// CHILD:  !DICompositeType(tag: DW_TAG_class_type, name: "A"
+// CHILD-SAME: flags: DIFlagFwdDecl
+// CHILD-SAME: templateParams: [[PARAM_LIST:![0-9]*]]
+// CHILD:  [[PARAM_LIST]] = !{[[PARAM:![0-9]*]]}
+// CHILD:  [[PARAM]] = !DITemplateTypeParameter(name: "T",
+// CHILD-SAME: type: [[CTYPE:![0-9]*]]
+// CHILD:  [[CTYPE]] = !DIDerivedType(tag: DW_TAG_const_type
+// CHILD-SAME: baseType: [[BTYPE:![0-9]*]]
+// CHILD:  [[BTYPE]] = !DIBasicType(name: "int"
+
+// NONE:   !DICompositeType(tag: DW_TAG_class_type, name: "A"
+// NONE-SAME:  flags: DIFlagFwdDecl
+// NONE-NOT:   templateParams:
+// NONE-SAME:  )
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2201,6 +2201,7 @@
   Opts.EncodeExtendedBlockSig =
 Args.hasArg(OPT_fencode_extended_block_signature);
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
+  Opts.EmitFwdTemplateChildren = Args.hasArg(OPT_fdebug_forward_template_params);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2969,6 +2969,13 @@
 CmdArgs.push_back("-generate-type-units");
   }
 
+  // Decide how to render forward declarations of template instantiations.
+  // SCE defaults to on, others default to off.
+  if (Args.hasFlag(options::OPT_fdebug_forward_template_params,
+   options::OPT_fno_debug_forward_template_params,
+   DebuggerTuning == llvm::DebuggerKind::SCE))
+CmdArgs.push_back("-fdebug-forward-template-params");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -833,6 +833,10 @@
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
   llvm::DINode::FlagFwdDecl, FullName);
+  if (CG

[PATCH] D37891: Driver: hoist the `wchar_t` handling to the driver

2017-09-26 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:477
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
-  assert((LangOpts.ShortWChar ||
-  llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) 
==

compnerd wrote:
> compnerd wrote:
> > MatzeB wrote:
> > > rnk wrote:
> > > > @MatzeB ptal
> > > Can you find a new place for this assert()? Please do not just remove it!
> > > 
> > > For the backstory: Unfortunately I had to duplicate the wchar decision 
> > > logic inside llvm (TargetLibraryInfoImpl::getTargetWCharSize() for cases 
> > > where we just have the target triple available but need to know the size 
> > > of wchar_t using library function. This means the logic in LLVM needs to 
> > > be updated when support for new platforms is added but for people adding 
> > > platform support it will not be obvious that they have the change 
> > > LLVM/TargetLibraryInfo as well unless an assert() point them to there 
> > > being a mismatch.
> > Sure, I'll try to see if I can find a suitable place or adjustment of it.  
> > However, one thing to note is that the frontend does actually embed that 
> > into the IR metadata ("wchar_size"). 
> I think that if we try to retain this assertion, we need to update all the 
> tests to ensure that they pass the arguments for selecting the `wchar_t` 
> type.  The entire problem is that the backend view of this cannot correlate 
> with what the user specified without passing it back to it.  The "wchar_size" 
> metadata does exactly that.  Using that to perform the validation for the 
> library function call.
This has been resolved with r314187 that made the assertion obsolete.


Repository:
  rL LLVM

https://reviews.llvm.org/D37891



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


[PATCH] D38074: Fix TBAA information for reference accesses

2017-09-26 Thread Ivan A. Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314209: Fix TBAA information for reference accesses 
(authored by kosarev).

Changed prior to commit:
  https://reviews.llvm.org/D38074?vs=116326&id=116721#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38074

Files:
  cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
  cfe/trunk/test/CodeGen/tbaa-reference.cpp


Index: cfe/trunk/test/CodeGen/tbaa-reference.cpp
===
--- cfe/trunk/test/CodeGen/tbaa-reference.cpp
+++ cfe/trunk/test/CodeGen/tbaa-reference.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm 
-o - | FileCheck %s
+//
+// Check that we generate correct TBAA information for reference accesses.
+
+struct S;
+
+struct B {
+  S &s;
+  B(S &s) : s(s) {}
+  void bar();
+};
+
+void foo(S &s) {
+  B b(s);
+  b.bar();
+}
+
+// CHECK-LABEL: _Z3fooR1S
+// Check initialization of the reference parameter in foo().
+// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa 
[[TAG_pointer:!.*]]
+//
+// CHECK-LABEL: _ZN1BC2ER1S
+// TODO: Check loading of the reference parameter in B::B(S&).
+// Check initialization of B::s in B::B(S&).
+// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa [[TAG_pointer]]
+//
+// CHECK-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 
0}
+// CHECK-DAG: [[TYPE_pointer]] = !{!"any pointer", [[TYPE_char:!.*]], i64 0}
+// CHECK-DAG: [[TYPE_char]] = !{!"omnipotent char", {{!.*}}, i64 0}
Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
@@ -145,10 +145,10 @@
   if (Ty->isStdByteType())
 return MetadataCache[Ty] = getChar();
 
-  // Handle pointers.
+  // Handle pointers and references.
   // TODO: Implement C++'s type "similarity" and consider dis-"similar"
   // pointers distinct.
-  if (Ty->isPointerType())
+  if (Ty->isPointerType() || Ty->isReferenceType())
 return MetadataCache[Ty] = createTBAAScalarType("any pointer",
 getChar());
 


Index: cfe/trunk/test/CodeGen/tbaa-reference.cpp
===
--- cfe/trunk/test/CodeGen/tbaa-reference.cpp
+++ cfe/trunk/test/CodeGen/tbaa-reference.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
+//
+// Check that we generate correct TBAA information for reference accesses.
+
+struct S;
+
+struct B {
+  S &s;
+  B(S &s) : s(s) {}
+  void bar();
+};
+
+void foo(S &s) {
+  B b(s);
+  b.bar();
+}
+
+// CHECK-LABEL: _Z3fooR1S
+// Check initialization of the reference parameter in foo().
+// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa [[TAG_pointer:!.*]]
+//
+// CHECK-LABEL: _ZN1BC2ER1S
+// TODO: Check loading of the reference parameter in B::B(S&).
+// Check initialization of B::s in B::B(S&).
+// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa [[TAG_pointer]]
+//
+// CHECK-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0}
+// CHECK-DAG: [[TYPE_pointer]] = !{!"any pointer", [[TYPE_char:!.*]], i64 0}
+// CHECK-DAG: [[TYPE_char]] = !{!"omnipotent char", {{!.*}}, i64 0}
Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
@@ -145,10 +145,10 @@
   if (Ty->isStdByteType())
 return MetadataCache[Ty] = getChar();
 
-  // Handle pointers.
+  // Handle pointers and references.
   // TODO: Implement C++'s type "similarity" and consider dis-"similar"
   // pointers distinct.
-  if (Ty->isPointerType())
+  if (Ty->isPointerType() || Ty->isReferenceType())
 return MetadataCache[Ty] = createTBAAScalarType("any pointer",
 getChar());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38168: [mips] Accept but ignore -m(no-)branch-likely

2017-09-26 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314213: [mips] Accept but ignore -m(no-)branch-likely 
(authored by sdardis).

Repository:
  rL LLVM

https://reviews.llvm.org/D38168

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/test/Driver/mips-features.c


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2047,6 +2047,10 @@
 def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">,
   Group;
 def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group;
+def mbranch_likely : Flag<["-"], "mbranch-likely">, Group,
+  IgnoredGCCCompat;
+def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group,
+  IgnoredGCCCompat;
 def mdsp : Flag<["-"], "mdsp">, Group;
 def mno_dsp : Flag<["-"], "mno-dsp">, Group;
 def mdspr2 : Flag<["-"], "mdspr2">, Group;
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -392,3 +392,13 @@
 // LONG-CALLS-ON: "-target-feature" "+long-calls"
 // LONG-CALLS-OFF: "-target-feature" "-long-calls"
 // LONG-CALLS-DEF-NOT: "long-calls"
+//
+// -mbranch-likely
+// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \
+// RUN:   | FileCheck --check-prefix=BRANCH-LIKELY %s
+// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely'
+//
+// -mno-branch-likely
+// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \
+// RUN:   | FileCheck --check-prefix=NO-BRANCH-LIKELY %s
+// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely'


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2047,6 +2047,10 @@
 def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">,
   Group;
 def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group;
+def mbranch_likely : Flag<["-"], "mbranch-likely">, Group,
+  IgnoredGCCCompat;
+def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group,
+  IgnoredGCCCompat;
 def mdsp : Flag<["-"], "mdsp">, Group;
 def mno_dsp : Flag<["-"], "mno-dsp">, Group;
 def mdspr2 : Flag<["-"], "mdspr2">, Group;
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -392,3 +392,13 @@
 // LONG-CALLS-ON: "-target-feature" "+long-calls"
 // LONG-CALLS-OFF: "-target-feature" "-long-calls"
 // LONG-CALLS-DEF-NOT: "long-calls"
+//
+// -mbranch-likely
+// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \
+// RUN:   | FileCheck --check-prefix=BRANCH-LIKELY %s
+// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely'
+//
+// -mno-branch-likely
+// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \
+// RUN:   | FileCheck --check-prefix=NO-BRANCH-LIKELY %s
+// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38243: [clang-format] Add ext/ to google include categories

2017-09-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314211: [clang-format] Add ext/ to google include categories 
(authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D38243

Files:
  cfe/trunk/lib/Format/Format.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -665,7 +665,8 @@
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
-  GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeCategories = {
+  {"^", 2}, {"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -665,7 +665,8 @@
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
-  GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeCategories = {
+  {"^", 2}, {"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36737: [analyzer] Store design discussions in docs/analyzer for future use.

2017-09-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314218: [analyzer] Keep track of design discusions as part 
of analyzer documentation. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D36737?vs=116520&id=116724#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36737

Files:
  cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst

Index: cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst
===
--- cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst
+++ cfe/trunk/docs/analyzer/DesignDiscussions/InitializerLists.rst
@@ -0,0 +1,321 @@
+This discussion took place in https://reviews.llvm.org/D35216
+"Escape symbols when creating std::initializer_list".
+
+It touches problems of modelling C++ standard library constructs in general,
+including modelling implementation-defined fields within C++ standard library
+objects, in particular constructing objects into pointers held by such fields,
+and separation of responsibilities between analyzer's core and checkers.
+
+**Artem:**
+
+I've seen a few false positives that appear because we construct
+C++11 std::initializer_list objects with brace initializers, and such
+construction is not properly modeled. For instance, if a new object is
+constructed on the heap only to be put into a brace-initialized STL container,
+the object is reported to be leaked.
+
+Approach (0): This can be trivially fixed by this patch, which causes pointers
+passed into initializer list expressions to immediately escape.
+
+This fix is overly conservative though. So i did a bit of investigation as to
+how model std::initializer_list better.
+
+According to the standard, std::initializer_list is an object that has
+methods begin(), end(), and size(), where begin() returns a pointer to continous
+array of size() objects of type T, and end() is equal to begin() plus size().
+The standard does hint that it should be possible to implement
+std::initializer_list as a pair of pointers, or as a pointer and a size
+integer, however specific fields that the object would contain are an
+implementation detail.
+
+Ideally, we should be able to model the initializer list's methods precisely.
+Or, at least, it should be possible to explain to the analyzer that the list
+somehow "takes hold" of the values put into it. Initializer lists can also be
+copied, which is a separate story that i'm not trying to address here.
+
+The obvious approach to modeling std::initializer_list in a checker would be to
+construct a SymbolMetadata for the memory region of the initializer list object,
+which would be of type T* and represent begin(), so we'd trivially model begin()
+as a function that returns this symbol. The array pointed to by that symbol
+would be bindLoc()ed to contain the list's contents (probably as a CompoundVal
+to produce less bindings in the store). Extent of this array would represent
+size() and would be equal to the length of the list as written.
+
+So this sounds good, however apparently it does nothing to address our false
+positives: when the list escapes, our RegionStoreManager is not magically
+guessing that the metadata symbol attached to it, together with its contents,
+should also escape. In fact, it's impossible to trigger a pointer escape from
+within the checker.
+
+Approach (1): If only we enabled ProgramState::bindLoc(..., notifyChanges=true)
+to cause pointer escapes (not only region changes) (which sounds like the right
+thing to do anyway) such checker would be able to solve the false positives by
+triggering escapes when binding list elements to the list. However, it'd be as
+conservative as the current patch's solution. Ideally, we do not want escapes to
+happen so early. Instead, we'd prefer them to be delayed until the list itself
+escapes.
+
+So i believe that escaping metadata symbols whenever their base regions escape
+would be the right thing to do. Currently we didn't think about that because we
+had neither pointer-type metadatas nor non-pointer escapes.
+
+Approach (2): We could teach the Store to scan itself for bindings to
+metadata-symbolic-based regions during scanReachableSymbols() whenever a region
+turns out to be reachable. This requires no work on checker side, but it sounds
+performance-heavy.
+
+Approach (3): We could let checkers maintain the set of active metadata symbols
+in the program state (ideally somewhere in the Store, which sounds weird but
+causes the smallest amount of layering violations), so that the core knew what
+to escape. This puts a stress on the checkers, but with a smart data map it
+wouldn't be a problem.
+
+Approach (4): We could allow checkers to trigger pointer escapes in arbitrary
+moments. If we allow doing this within checkPointerEscape callback itself, we
+would be able to express facts like "when this region escapes, that metadata
+symbol attached to it should also

[PATCH] D38203: [Sema] Corrected the warn-on-throw-from-noexcept behavior to include nothrow

2017-09-26 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314229: [Sema] Corrected the warn-on-throw-from-noexcept 
behavior to include nothrow (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38203?vs=116426&id=116729#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38203

Files:
  cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
  cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp


Index: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
===
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -std=c++11
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions 
-fsyntax-only -Wexceptions -verify -fdeclspec -std=c++11
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
@@ -14,6 +14,15 @@
   ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing 
exception specification}}
 throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
   }
+  __attribute__((nothrow)) R_ShouldDiag() {// expected-note {{function 
declared non-throwing here}}
+throw 1;// expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __attribute__((nothrow)) SomeThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
+  void __declspec(nothrow) SomeDeclspecThrow() {// expected-note {{function 
declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification 
but}}
+  }
 };
 
 struct M_ShouldNotDiag {
Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -426,7 +426,7 @@
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs();
-  if (FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()) || FD->hasAttr())
 return true;
   return false;
 }


Index: cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
===
--- cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
+++ cfe/trunk/test/SemaCXX/warn-throw-out-noexcept-func.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++11
+// RUN: %clang_cc1 %s  -fdelayed-template-parsing -fcxx-exceptions -fsyntax-only -Wexceptions -verify -fdeclspec -std=c++11
 struct A_ShouldDiag {
   ~A_ShouldDiag(); // implicitly noexcept(true)
 };
@@ -14,6 +14,15 @@
   ~R_ShouldDiag() { // expected-note  {{destructor has a implicit non-throwing exception specification}}
 throw 1; // expected-warning {{has a non-throwing exception specification but}}
   }
+  __attribute__((nothrow)) R_ShouldDiag() {// expected-note {{function declared non-throwing here}}
+throw 1;// expected-warning {{has a non-throwing exception specification but}}
+  }
+  void __attribute__((nothrow)) SomeThrow() {// expected-note {{function declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification but}}
+  }
+  void __declspec(nothrow) SomeDeclspecThrow() {// expected-note {{function declared non-throwing here}}
+   throw 1; // expected-warning {{has a non-throwing exception specification but}}
+  }
 };
 
 struct M_ShouldNotDiag {
Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -426,7 +426,7 @@
 
 static bool isNoexcept(const FunctionDecl *FD) {
   const auto *FPT = FD->getType()->castAs();
-  if (FPT->isNothrow(FD->getASTContext()))
+  if (FPT->isNothrow(FD->getASTContext()) || FD->hasAttr())
 return true;
   return false;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36487: Emit section information for extern variables.

2017-09-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36487



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


[libcxx] r314258 - [libcxx] [test] Strip trailing whitespace.

2017-09-26 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Tue Sep 26 16:08:41 2017
New Revision: 314258

URL: http://llvm.org/viewvc/llvm-project?rev=314258&view=rev
Log:
[libcxx] [test] Strip trailing whitespace.

Modified:

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp?rev=314258&r1=314257&r2=314258&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp
 Tue Sep 26 16:08:41 2017
@@ -18,7 +18,7 @@
 
 #include "test_macros.h"
 #include "min_allocator.h"
- 
+
 template 
 void
 test(S s, typename S::size_type pos, SV sv, S expected)


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


[libcxx] r314257 - [libcxx] [test] Silence warning C4324 for MSVC.

2017-09-26 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Tue Sep 26 16:08:39 2017
New Revision: 314257

URL: http://llvm.org/viewvc/llvm-project?rev=314257&view=rev
Log:
[libcxx] [test] Silence warning C4324 for MSVC.

This warning "structure was padded due to alignment specifier" says
that the compiler is going to do exactly what you asked it to do.
It's triggered by the tests for over-aligned dynamic memory allocation.

Modified:
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=314257&r1=314256&r2=314257&view=diff
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Tue Sep 26 16:08:39 
2017
@@ -54,6 +54,7 @@ const AssertionDialogAvoider assertion_d
 
 // Silence compiler warnings.
 #pragma warning(disable: 4180) // qualifier applied to function type has 
no meaning; ignored
+#pragma warning(disable: 4324) // structure was padded due to alignment 
specifier
 #pragma warning(disable: 4521) // multiple copy constructors specified
 #pragma warning(disable: 4702) // unreachable code
 #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this 
instance has no annotations.


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


[libcxx] r314259 - [libcxx] [test] Fix unused local typedef warnings.

2017-09-26 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Tue Sep 26 16:08:43 2017
New Revision: 314259

URL: http://llvm.org/viewvc/llvm-project?rev=314259&view=rev
Log:
[libcxx] [test] Fix unused local typedef warnings.

Modified:

libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp?rev=314259&r1=314258&r2=314259&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
 Tue Sep 26 16:08:43 2017
@@ -150,8 +150,8 @@ int main()
 }
 #if TEST_STD_VER >= 11
 {
-typedef std::basic_string, 
min_allocator> S;
-typedef std::string_view SV;
+// typedef std::basic_string, 
min_allocator> S;
+// typedef std::string_view SV;
 // test0();
 // test1();
 }


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


[libclc] r314261 - Add missing HAVE_LLVM define to fix build with latest llvm

2017-09-26 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Sep 26 16:15:54 2017
New Revision: 314261

URL: http://llvm.org/viewvc/llvm-project?rev=314261&view=rev
Log:
Add missing HAVE_LLVM define to fix build with latest llvm

Broken since r314111

V2: pointed out by Jan Vesely
   - Use format() instead of % formating

Patch-by: Pavel Ondračka 
Signed-off-by: Pavel Ondračka 
Reviewed-by: Jan Vesely 

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=314261&r1=314260&r2=314261&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Tue Sep 26 16:15:54 2017
@@ -81,7 +81,8 @@ llvm_bindir = llvm_config(['--bindir'])
 llvm_core_libs = llvm_config(['--libs', 'core', 'bitreader', 'bitwriter']) + ' 
' + \
  llvm_system_libs + ' ' + \
  llvm_config(['--ldflags'])
-llvm_cxxflags = llvm_config(['--cxxflags']) + ' -fno-exceptions -fno-rtti'
+llvm_cxxflags = llvm_config(['--cxxflags']) + ' -fno-exceptions -fno-rtti ' + \
+'-DHAVE_LLVM=0x{:0=4}'.format(llvm_int_version)
 llvm_libdir = llvm_config(['--libdir'])
 
 llvm_clang = os.path.join(llvm_bindir, 'clang')


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


[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2017-09-26 Thread Wei Mi via Phabricator via cfe-commits
wmi added a comment.

In https://reviews.llvm.org/D36562#880808, @hfinkel wrote:

> You seem to be only changing the behavior for the "separatable" fields, but I 
> suspect you want to change the behavior for the others too. The bitfield 
> would be decomposed into shards, separated by the naturally-sized-and-aligned 
> fields. Each access only loads its shard. For example, in your test case you 
> have:
>
>   struct S3 {
> unsigned long f1:14;
> unsigned long f2:18;
> unsigned long f3:32;
>   };
>   
>
> and you test that, with this option, loading/storing to a3.f3 only access the 
> specific 4 bytes composing f3. But if you load f1 or f2, we're still loading 
> all 8 bytes, right? I think we should only load/store the lower 4 bytes when 
> we access a3.f1 and/or a3.f2.


This is intentional. if the struct S3 is like following:
struct S3 {

  unsigned long f1:14;
  unsigned long f2:32;
  unsigned long f3:18;

};

and if there is no write of a.f2 between a.f1 and a.f3, the loads of a.f1 and 
a.f2 can still be shared. It is trying to keep the combining opportunity 
maximally while reducing the cost of accessing naturally-sized-and-aligned 
fields

> Otherwise, you can again end up with the narrow-store/wide-load problem for 
> nearby fields under a different set of circumstances.

Good catch. It is possible to have the problem indeed. Considering the big perf 
impact and triaging difficulty of store-forwarding problem, I have to sacrifice 
the combining opportunity above and take the suggestion just as you describe.

Thanks,
Wei.




Comment at: include/clang/Driver/Options.td:1032
 
+def fsplit_bitfields : Flag<["-"], "fsplit-bitfields">,
+  Group, Flags<[CC1Option]>,

hfinkel wrote:
> I'm not opposed to -fsplit-bitfields, but I'd prefer if we find something 
> more self-explanatory. It's not really clear what "splitting a bitfield" 
> means. Maybe?
> 
>   -fsplit-bitfield-accesses
>   -fdecomposed-bitfield-accesses
>   -fsharded-bitfield-accesses
>   -ffine-grained-bitfield-accesses
> 
> (I think that I prefer -ffine-grained-bitfield-accesses, although it's the 
> longest)
Ok. 



Comment at: include/clang/Driver/Options.td:1034
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enable splitting bitfield with legal width and alignment in 
LLVM.">;
+def fno_split_bitfields : Flag<["-"], "fno-split-bitfields">,

hfinkel wrote:
> How about?
> 
>   Use separate access for bitfields with legal widths and alignments.
> 
> I don't think that "in LLVM" is needed here (or we could put "in LLVM" on an 
> awful lot of these options).
Sure.


Repository:
  rL LLVM

https://reviews.llvm.org/D36562



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


r314262 - Emit section information for extern variables.

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 16:42:34 2017
New Revision: 314262

URL: http://llvm.org/viewvc/llvm-project?rev=314262&view=rev
Log:
Emit section information for extern variables. 

Currently, if _attribute_((section())) is used for extern variables, 
section information is not emitted in generated IR when the variables are used. 
This is expected since sections are not generated for external linkage objects. 
However NiosII requires this information as it uses special GP-relative 
accesses 
for any objects that use attribute section (.sdata). GCC keeps this attribute 
in 
  middle-end.

This change emits the section information for all targets.

Patch By: Elizabeth Andrews

Differential Revision:https://reviews.llvm.org/D36487


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/attr-section.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 26 16:42:34 
2017
@@ -2620,6 +2620,8 @@ def err_attribute_section_invalid_for_ta
   "argument to 'section' attribute is not valid for this target: %0">;
 def warn_mismatched_section : Warning<
   "section does not match previous declaration">, InGroup;
+def warn_attribute_section_on_redeclaration : Warning<
+  "section attribute is specified on redeclared variable">, InGroup;
 
 def err_anonymous_property: Error<
   "anonymous property is not supported">;

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Sep 26 16:42:34 2017
@@ -2432,6 +2432,12 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep 26 16:42:34 2017
@@ -2607,6 +2607,16 @@ void Sema::mergeDeclAttributes(NamedDecl
 }
   }
 
+  // This redeclaration adds a section attribute.
+  if (New->hasAttr() && !Old->hasAttr()) {
+if (auto *VD = dyn_cast(New)) {
+  if (VD->isThisDeclarationADefinition() != VarDecl::Definition) {
+Diag(New->getLocation(), 
diag::warn_attribute_section_on_redeclaration);
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
+}
+  }
+
   if (!Old->hasAttrs())
 return;
 

Modified: cfe/trunk/test/Sema/attr-section.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-section.c?rev=314262&r1=314261&r2=314262&view=diff
==
--- cfe/trunk/test/Sema/attr-section.c (original)
+++ cfe/trunk/test/Sema/attr-section.c Tue Sep 26 16:42:34 2017
@@ -19,3 +19,7 @@ void __attribute__((section("foo,zed")))
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning 
{{section does not match previous declaration}}
 
 enum __attribute__((section("NEAR,x"))) e { one }; // expected-error 
{{'section' attribute only applies to functions, methods, properties, and 
global variables}}
+
+extern int a; // expected-note {{previous declaration is here}}
+int *b = &a;
+extern int a __attribute__((section("foo,zed"))); // expected-warning 
{{section attribute is specified on redeclared variable}}


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


[PATCH] D36487: Emit section information for extern variables.

2017-09-26 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314262: Emit section information for extern variables.  
(authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D36487?vs=116581&id=116739#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36487

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/attr-section.c


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2432,6 +2432,12 @@
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -2607,6 +2607,16 @@
 }
   }
 
+  // This redeclaration adds a section attribute.
+  if (New->hasAttr() && !Old->hasAttr()) {
+if (auto *VD = dyn_cast(New)) {
+  if (VD->isThisDeclarationADefinition() != VarDecl::Definition) {
+Diag(New->getLocation(), 
diag::warn_attribute_section_on_redeclaration);
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
+}
+  }
+
   if (!Old->hasAttrs())
 return;
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2620,6 +2620,8 @@
   "argument to 'section' attribute is not valid for this target: %0">;
 def warn_mismatched_section : Warning<
   "section does not match previous declaration">, InGroup;
+def warn_attribute_section_on_redeclaration : Warning<
+  "section attribute is specified on redeclared variable">, InGroup;
 
 def err_anonymous_property: Error<
   "anonymous property is not supported">;
Index: cfe/trunk/test/Sema/attr-section.c
===
--- cfe/trunk/test/Sema/attr-section.c
+++ cfe/trunk/test/Sema/attr-section.c
@@ -19,3 +19,7 @@
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning 
{{section does not match previous declaration}}
 
 enum __attribute__((section("NEAR,x"))) e { one }; // expected-error 
{{'section' attribute only applies to functions, methods, properties, and 
global variables}}
+
+extern int a; // expected-note {{previous declaration is here}}
+int *b = &a;
+extern int a __attribute__((section("foo,zed"))); // expected-warning 
{{section attribute is specified on redeclared variable}}


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2432,6 +2432,12 @@
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -2607,6 +2607,16 @@
 }
   }
 
+  // This redeclaration adds a section attribute.
+  if (New->hasAttr() && !Old->hasAttr()) {
+if (auto *VD = dyn_cast(New)) {
+  if (VD->isThisDeclarationADefinition() != VarDecl::Definition) {
+Diag(New->getLocation(), diag::warn_attribute_section_on_redeclaration);
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
+}
+  }
+
   if (!Old->hasAttrs())
 return;
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2620,6 +2620,8 @@
   "argument to 'section' attribute is not valid for this target: %0">;
 def warn_mismatched_section : Warning<
   "section does not match previous declaration">, InGroup;
+def warn_attribute_section_on_redeclaration : Warning<
+  "section attribute is specified on redeclared variable">, InGroup;
 
 def err_anonymous_property: Error<
   "anonymous property is not supported">;

RE: r314235 - Allow IUnknown/IInterface types to come from extern C++

2017-09-26 Thread Keane, Erich via cfe-commits
BTW: The guy who told me about this issue ALSO discovered a different issue 
that that I didn't solve due to his reproducer not contining the whole 
testcase.  I've got a patch to fix all of it in his hands right now, so I'll 
submit this fix with it together.

-Erich

-Original Message-
From: Friedman, Eli [mailto:efrie...@codeaurora.org] 
Sent: Tuesday, September 26, 2017 12:06 PM
To: Keane, Erich ; cfe-commits@lists.llvm.org
Subject: Re: r314235 - Allow IUnknown/IInterface types to come from extern C++

On 9/26/2017 11:55 AM, Erich Keane via cfe-commits wrote:
> Author: erichkeane
> Date: Tue Sep 26 11:55:16 2017
> New Revision: 314235
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314235&view=rev
> Log:
> Allow IUnknown/IInterface types to come from extern C++
>
> It was brought up in response to my last implementation for this 
> struct-as-interface features that at least 1 header in the MS SDK uses 
> "extern C++" around an IUnknown declaration.
>
> The previous implementation demanded that this type exist in the 
> TranslationUnit DeclContext.  This small change simply also allows in 
> the situation where we're extern "C++".
>
> Modified:
>  cfe/trunk/lib/AST/DeclCXX.cpp
>  cfe/trunk/test/SemaCXX/ms-iunknown.cpp
>
> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=
> 314235&r1=314234&r2=314235&view=diff
> ==
> 
> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
> +++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Sep 26 11:55:16 2017
> @@ -1491,7 +1491,8 @@ bool CXXRecordDecl::isInterfaceLike() co
>   
> // Check "Special" types.
> const auto *Uuid = getAttr();
> -  if (Uuid && isStruct() && getDeclContext()->isTranslationUnit() &&
> +  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
> + getDeclContext()->isExternCXXContext()) 
> + &&

Do you need to check that the "extern C++" is actually a direct child of the 
translation unit?  Consider, e.g. `namespace X { extern "C++"`...

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


[PATCH] D37023: [analyzer] Fix bugreporter::getDerefExpr() again.

2017-09-26 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.

LGTM! Thanks Artem.


https://reviews.llvm.org/D37023



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


[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Does this have to be exposed through the driver or could this be a cc1 option 
only?




Comment at: include/clang/Basic/LangOptions.def:144
 BENIGN_LANGOPT(EmitAllDecls  , 1, 0, "emitting all declarations")
+BENIGN_LANGOPT(EmitFwdTemplateChildren, 1, 0, "emit template parameter 
children in forward declarations")
 LANGOPT(MathErrno , 1, 1, "errno in math functions")

Why is this a LangOpt instead of a CodeGenOpt?
Should it reference `debug` somewhere in the name?


https://reviews.llvm.org/D14358



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


[PATCH] D37695: [clang-format] Break non-trailing comments, try 2

2017-09-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 116742.
krasimir added a comment.

- Change bool from Paren to Line and generalize it


https://reviews.llvm.org/D37695

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  unittests/Format/FormatTestComments.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -65,6 +65,27 @@
 TEST_F(FormatTestJS, BlockComments) {
   verifyFormat("/* a */ aaa(\n"
"aaa);");
+  // Breaks after a single line block comment.
+  EXPECT_EQ("a = .ccc(\n"
+"/** @type_{!.rrr..LLL.lala} */\n"
+"mediaMessage);",
+format("a = .ccc(\n"
+   "/** "
+   "@type_{!.rrr..LLL.lala} */ "
+   "mediaMessage);",
+   getGoogleJSStyleWithColumns(70)));
+  // Breaks after a multiline block comment.
+  EXPECT_EQ(
+  "a = .ccc(\n"
+  "/**\n"
+  " * @type_{!.rrr..LLL.lala}\n"
+  " */\n"
+  "mediaMessage);",
+  format("a = .ccc(\n"
+ "/**\n"
+ " * @type_{!.rrr..LLL.lala}\n"
+ " */ mediaMessage);",
+ getGoogleJSStyleWithColumns(70)));
 }
 
 TEST_F(FormatTestJS, JSDocComments) {
Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -2407,6 +2407,57 @@
getLLVMStyleWithColumns(15)));
 }
 
+TEST_F(FormatTestComments, BreaksAfterMultilineBlockCommentsInParamLists) {
+  EXPECT_EQ("a = f(/* long\n"
+" long\n"
+"   */\n"
+"  a);",
+format("a = f(/* long long */ a);", getLLVMStyleWithColumns(15)));
+
+  EXPECT_EQ("a = f(/* long\n"
+" long\n"
+"   */\n"
+"  a);",
+format("a = f(/* long\n"
+   " long\n"
+   "   */a);",
+   getLLVMStyleWithColumns(15)));
+
+  EXPECT_EQ("a = f(/* long\n"
+" long\n"
+"   */\n"
+"  a);",
+format("a = f(/* long\n"
+   " long\n"
+   "   */ a);",
+   getLLVMStyleWithColumns(15)));
+
+  EXPECT_EQ("a = f(/* long\n"
+" long\n"
+"   */\n"
+"  (1 + 1));",
+format("a = f(/* long\n"
+   " long\n"
+   "   */ (1 + 1));",
+   getLLVMStyleWithColumns(15)));
+
+  EXPECT_EQ(
+  "a = f(a,\n"
+  "  /* long\n"
+  " long\n"
+  "   */\n"
+  "  b);",
+  format("a = f(a, /* long long */ b);", getLLVMStyleWithColumns(15)));
+
+  EXPECT_EQ(
+  "a = f(a,\n"
+  "  /* long\n"
+  " long\n"
+  "   */\n"
+  "  (1 + 1));",
+  format("a = f(a, /* long long */ (1 + 1));", getLLVMStyleWithColumns(15)));
+}
+
 TEST_F(FormatTestComments, IndentLineCommentsInStartOfBlockAtEndOfFile) {
   verifyFormat("{\n"
"  // a\n"
@@ -2805,6 +2856,22 @@
   getLLVMStyleWithColumns(80)));
   // clang-format on
 }
+
+TEST_F(FormatTestComments, NonTrailingBlockComments) {
+  verifyFormat("const /** comment comment */ A = B;",
+   getLLVMStyleWithColumns(40));
+
+  verifyFormat("const /** comment comment comment */ A =\n"
+   "B;",
+   getLLVMStyleWithColumns(40));
+
+  EXPECT_EQ("const /** comment comment comment\n"
+" comment */\n"
+"A = B;",
+format("const /** comment comment comment comment */\n"
+   "A = B;",
+   getLLVMStyleWithColumns(40)));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -318,6 +318,9 @@
   /// \brief \c true if this line contains a continued for-loop section.
   bool LineContainsContinuedForLoopSection;
 
+  /// \brief \c true if \p NextToken should not continue this line.
+  bool NoContinuation;
+
   /// \brief The \c NestingLevel at the start of this line.
   unsigned StartOfLineLevel;
 
@@ -364,6 +367,8 @@
 if (LineContainsContinuedForLoop

Re: [PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-26 Thread Krasimir Georgiev via cfe-commits
I'm currently at cppcon with limited bandwidth for reviews. I believe that
the literal test that I mentioned put inside the namespace fixer test suite
fails before your changes, could you please double check?

On Tue, 26 Sep 2017, 15:30 Marek Kurdej via Phabricator, <
revi...@reviews.llvm.org> wrote:

> curdeius added a comment.
>
> Any thoughts on this?
>
>
> https://reviews.llvm.org/D37904
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea reopened this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

Open


https://reviews.llvm.org/D38040



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


[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-26 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314264: [clang-format] Adjust space around &/&& of 
structured bindings (authored by chh).

Changed prior to commit:
  https://reviews.llvm.org/D35743?vs=116201&id=116744#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35743

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -342,10 +342,10 @@
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->is(TT_Unknown)) {
-  if (Left->isCppStructuredBinding(Style)) {
-Left->Type = TT_StructuredBindingLSquare;
-  } else if (StartsObjCMethodExpr) {
+if (Left->isCppStructuredBinding(Style)) {
+  Left->Type = TT_StructuredBindingLSquare;
+} else if (Left->is(TT_Unknown)) {
+  if (StartsObjCMethodExpr) {
 Left->Type = TT_ObjCMethodExpr;
   } else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
  Contexts.back().ContextKind == tok::l_brace &&
@@ -2515,6 +2515,14 @@
   TT_TemplateOpener));
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return Style.SpacesInAngles;
+  // Space before TT_StructuredBindingLSquare.
+  if (Right.is(TT_StructuredBindingLSquare))
+return !Left.isOneOf(tok::amp, tok::ampamp) ||
+   Style.PointerAlignment != FormatStyle::PAS_Right;
+  // Space before & or && following a TT_StructuredBindingLSquare.
+  if (Right.Next && Right.Next->is(TT_StructuredBindingLSquare) &&
+  Right.isOneOf(tok::amp, tok::ampamp))
+return Style.PointerAlignment != FormatStyle::PAS_Left;
   if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
   (Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
!Right.is(tok::r_paren)))
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -11579,24 +11579,59 @@
   EXPECT_EQ("auto const volatile [a, b] = f();",
 format("auto  const   volatile[a, b] = f();"));
   EXPECT_EQ("auto [a, b, c] = f();", format("auto   [  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto & [a, b, c] = f();",
+  EXPECT_EQ("auto &[a, b, c] = f();",
 format("auto   &[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto && [a, b, c] = f();",
+  EXPECT_EQ("auto &&[a, b, c] = f();",
 format("auto   &&[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto const & [a, b] = f();", format("auto  const&[a, b] = f();"));
-  EXPECT_EQ("auto const volatile && [a, b] = f();",
+  EXPECT_EQ("auto const &[a, b] = f();", format("auto  const&[a, b] = f();"));
+  EXPECT_EQ("auto const volatile &&[a, b] = f();",
 format("auto  const  volatile  &&[a, b] = f();"));
-  EXPECT_EQ("auto && [a, b] = f();", format("auto  &&[a, b] = f();"));
+  EXPECT_EQ("auto const &&[a, b] = f();", format("auto  const   &&  [a, b] = f();"));
+  EXPECT_EQ("const auto &[a, b] = f();", format("const  auto  &  [a, b] = f();"));
+  EXPECT_EQ("const auto volatile &&[a, b] = f();",
+format("const  auto   volatile  &&[a, b] = f();"));
+  EXPECT_EQ("volatile const auto &&[a, b] = f();",
+format("volatile  const  auto   &&[a, b] = f();"));
+  EXPECT_EQ("const auto &&[a, b] = f();", format("const  auto  &&  [a, b] = f();"));
 
   // Make sure we don't mistake structured bindings for lambdas.
-  verifyFormat("auto [a, b]{A * i};");
-  verifyFormat("auto const [a, b]{A * i};");
-  verifyFormat("auto const && [a, b]{A * i};");
+  FormatStyle PointerMiddle = getLLVMStyle();
+  PointerMiddle.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("auto [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const & [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const&& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &&[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const && [a3, b]{A * i};", PointerMiddle);
+
+  EXPECT_EQ("for (const auto &&[a, b] : some_range) {\n}",
+format("for (const auto   &&   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto &[a, b] : some_range) {\n}",
+format("for (const auto   &   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto [a, b] : some

r314264 - [clang-format] Adjust space around &/&& of structured bindings

2017-09-26 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Tue Sep 26 17:58:45 2017
New Revision: 314264

URL: http://llvm.org/viewvc/llvm-project?rev=314264&view=rev
Log:
[clang-format] Adjust space around &/&& of structured bindings

Keep space before or after the &/&& tokens, but not both. For example,
  auto [x,y] = a;
  auto &[xr, yr] = a; // LLVM style
  auto& [xr, yr] = a; // google style

Differential Revision:https://reviews.llvm.org/D35743


Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=314264&r1=314263&r2=314264&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Sep 26 17:58:45 2017
@@ -342,10 +342,10 @@ private:
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->is(TT_Unknown)) {
-  if (Left->isCppStructuredBinding(Style)) {
-Left->Type = TT_StructuredBindingLSquare;
-  } else if (StartsObjCMethodExpr) {
+if (Left->isCppStructuredBinding(Style)) {
+  Left->Type = TT_StructuredBindingLSquare;
+} else if (Left->is(TT_Unknown)) {
+  if (StartsObjCMethodExpr) {
 Left->Type = TT_ObjCMethodExpr;
   } else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
  Contexts.back().ContextKind == tok::l_brace &&
@@ -2515,6 +2515,14 @@ bool TokenAnnotator::spaceRequiredBefore
   TT_TemplateOpener));
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return Style.SpacesInAngles;
+  // Space before TT_StructuredBindingLSquare.
+  if (Right.is(TT_StructuredBindingLSquare))
+return !Left.isOneOf(tok::amp, tok::ampamp) ||
+   Style.PointerAlignment != FormatStyle::PAS_Right;
+  // Space before & or && following a TT_StructuredBindingLSquare.
+  if (Right.Next && Right.Next->is(TT_StructuredBindingLSquare) &&
+  Right.isOneOf(tok::amp, tok::ampamp))
+return Style.PointerAlignment != FormatStyle::PAS_Left;
   if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
   (Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
!Right.is(tok::r_paren)))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=314264&r1=314263&r2=314264&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Sep 26 17:58:45 2017
@@ -11579,24 +11579,59 @@ TEST_F(FormatTest, StructuredBindings) {
   EXPECT_EQ("auto const volatile [a, b] = f();",
 format("auto  const   volatile[a, b] = f();"));
   EXPECT_EQ("auto [a, b, c] = f();", format("auto   [  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto & [a, b, c] = f();",
+  EXPECT_EQ("auto &[a, b, c] = f();",
 format("auto   &[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto && [a, b, c] = f();",
+  EXPECT_EQ("auto &&[a, b, c] = f();",
 format("auto   &&[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto const & [a, b] = f();", format("auto  const&[a, b] = f();"));
-  EXPECT_EQ("auto const volatile && [a, b] = f();",
+  EXPECT_EQ("auto const &[a, b] = f();", format("auto  const&[a, b] = f();"));
+  EXPECT_EQ("auto const volatile &&[a, b] = f();",
 format("auto  const  volatile  &&[a, b] = f();"));
-  EXPECT_EQ("auto && [a, b] = f();", format("auto  &&[a, b] = f();"));
+  EXPECT_EQ("auto const &&[a, b] = f();", format("auto  const   &&  [a, b] = 
f();"));
+  EXPECT_EQ("const auto &[a, b] = f();", format("const  auto  &  [a, b] = 
f();"));
+  EXPECT_EQ("const auto volatile &&[a, b] = f();",
+format("const  auto   volatile  &&[a, b] = f();"));
+  EXPECT_EQ("volatile const auto &&[a, b] = f();",
+format("volatile  const  auto   &&[a, b] = f();"));
+  EXPECT_EQ("const auto &&[a, b] = f();", format("const  auto  &&  [a, b] = 
f();"));
 
   // Make sure we don't mistake structured bindings for lambdas.
-  verifyFormat("auto [a, b]{A * i};");
-  verifyFormat("auto const [a, b]{A * i};");
-  verifyFormat("auto const && [a, b]{A * i};");
+  FormatStyle PointerMiddle = getLLVMStyle();
+  PointerMiddle.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("auto [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const & [a

[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 116747.
gtbercea added a comment.

Fix test.


https://reviews.llvm.org/D38040

Files:
  test/OpenMP/openmp_offload_codegen.cpp


Index: test/OpenMP/openmp_offload_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/openmp_offload_codegen.cpp
@@ -0,0 +1,36 @@
+// Test device for mapping codegen.
+///==///
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -S -emit-llvm 
%s -o - 2>&1 \
+// RUN:   | FileCheck -check-prefix=CK1 %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc 
%s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck 
%s --check-prefix CK1-DEVICE
+
+// expected-no-diagnostics
+
+#ifdef CK1
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK1-DEVICE: {{.*}}void @__omp_offloading_{{.*}}(i32* 
dereferenceable(4){{.*}}
+
+// CK1: {{.*}}void {{.*}}target_maps_parallel_integer{{.*}} {
+
+// CK1: [[GEPOBP:%.+]] = getelementptr inbounds {{.*}}
+// CK1: [[GEPOBPBIT:%.+]] = bitcast i8** [[GEPOBP]]
+// CK1: store i32* %ParamToKernel, i32** [[GEPOBPBIT]]
+// CK1: [[GEPOP:%.+]] = getelementptr inbounds {{.*}}
+// CK1: [[GEPOPBIT:%.+]] = bitcast i8** [[GEPOP]]
+// CK1: store i32* %ParamToKernel, i32** [[GEPOPBIT]]
+// CK1: [[GEPOBPARG:%.+]] = getelementptr inbounds {{.*}}
+// CK1: [[GEPOPARG:%.+]] = getelementptr inbounds {{.*}}
+// CK1: call {{.*}}tgt_target({{.*}}i8** [[GEPOBPARG]], i8** [[GEPOPARG]]
+
+#endif
\ No newline at end of file


Index: test/OpenMP/openmp_offload_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/openmp_offload_codegen.cpp
@@ -0,0 +1,36 @@
+// Test device for mapping codegen.
+///==///
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -S -emit-llvm %s -o - 2>&1 \
+// RUN:   | FileCheck -check-prefix=CK1 %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK1-DEVICE
+
+// expected-no-diagnostics
+
+#ifdef CK1
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK1-DEVICE: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4){{.*}}
+
+// CK1: {{.*}}void {{.*}}target_maps_parallel_integer{{.*}} {
+
+// CK1: [[GEPOBP:%.+]] = getelementptr inbounds {{.*}}
+// CK1: [[GEPOBPBIT:%.+]] = bitcast i8** [[GEPOBP]]
+// CK1: store i32* %ParamToKernel, i32** [[GEPOBPBIT]]
+// CK1: [[GEPOP:%.+]] = getelementptr inbounds {{.*}}
+// CK1: [[GEPOPBIT:%.+]] = bitcast i8** [[GEPOP]]
+// CK1: store i32* %ParamToKernel, i32** [[GEPOPBIT]]
+// CK1: [[GEPOBPARG:%.+]] = getelementptr inbounds {{.*}}
+// CK1: [[GEPOPARG:%.+]] = getelementptr inbounds {{.*}}
+// CK1: call {{.*}}tgt_target({{.*}}i8** [[GEPOBPARG]], i8** [[GEPOPARG]]
+
+#endif
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314267 - Fix capitalization of a bunch of parameters in SemaDeclAttr [NFC]

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 20:20:13 2017
New Revision: 314267

URL: http://llvm.org/viewvc/llvm-project?rev=314267&view=rev
Log:
Fix capitalization of a bunch of parameters in SemaDeclAttr [NFC]

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

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=314267&r1=314266&r2=314267&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Sep 26 20:20:13 2017
@@ -1969,20 +1969,20 @@ static void handleNakedAttr(Sema &S, Dec
  
Attr.getAttributeSpellingListIndex()));
 }
 
-static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &attr) {
+static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
   if (hasDeclarator(D)) return;
 
-  if (S.CheckNoReturnAttr(attr))
+  if (S.CheckNoReturnAttr(Attrs))
 return;
 
   if (!isa(D)) {
-S.Diag(attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-<< attr.getName() << ExpectedFunctionOrMethod;
+S.Diag(Attrs.getLoc(), diag::warn_attribute_wrong_decl_type)
+<< Attrs.getName() << ExpectedFunctionOrMethod;
 return;
   }
 
   D->addAttr(::new (S.Context) NoReturnAttr(
-  attr.getRange(), S.Context, attr.getAttributeSpellingListIndex()));
+  Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
@@ -1994,9 +1994,9 @@ static void handleNoCallerSavedRegsAttr(
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
 
-bool Sema::CheckNoReturnAttr(const AttributeList &attr) {
-  if (!checkAttributeNumArgs(*this, attr, 0)) {
-attr.setInvalid();
+bool Sema::CheckNoReturnAttr(const AttributeList &Attrs) {
+  if (!checkAttributeNumArgs(*this, Attrs, 0)) {
+Attrs.setInvalid();
 return true;
   }
 
@@ -4303,24 +4303,24 @@ static void handleSuppressAttr(Sema &S,
   DiagnosticIdentifiers.size(), Attr.getAttributeSpellingListIndex()));
 }
 
-bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, 
+bool Sema::CheckCallingConvAttr(const AttributeList &Attrs, CallingConv &CC, 
 const FunctionDecl *FD) {
-  if (attr.isInvalid())
+  if (Attrs.isInvalid())
 return true;
 
-  if (attr.hasProcessingCache()) {
-CC = (CallingConv) attr.getProcessingCache();
+  if (Attrs.hasProcessingCache()) {
+CC = (CallingConv) Attrs.getProcessingCache();
 return false;
   }
 
-  unsigned ReqArgs = attr.getKind() == AttributeList::AT_Pcs ? 1 : 0;
-  if (!checkAttributeNumArgs(*this, attr, ReqArgs)) {
-attr.setInvalid();
+  unsigned ReqArgs = Attrs.getKind() == AttributeList::AT_Pcs ? 1 : 0;
+  if (!checkAttributeNumArgs(*this, Attrs, ReqArgs)) {
+Attrs.setInvalid();
 return true;
   }
 
   // TODO: diagnose uses of these conventions on the wrong target.
-  switch (attr.getKind()) {
+  switch (Attrs.getKind()) {
   case AttributeList::AT_CDecl: CC = CC_C; break;
   case AttributeList::AT_FastCall: CC = CC_X86FastCall; break;
   case AttributeList::AT_StdCall: CC = CC_X86StdCall; break;
@@ -4339,8 +4339,8 @@ bool Sema::CheckCallingConvAttr(const At
 break;
   case AttributeList::AT_Pcs: {
 StringRef StrRef;
-if (!checkStringLiteralArgumentAttr(attr, 0, StrRef)) {
-  attr.setInvalid();
+if (!checkStringLiteralArgumentAttr(Attrs, 0, StrRef)) {
+  Attrs.setInvalid();
   return true;
 }
 if (StrRef == "aapcs") {
@@ -4351,8 +4351,8 @@ bool Sema::CheckCallingConvAttr(const At
   break;
 }
 
-attr.setInvalid();
-Diag(attr.getLoc(), diag::err_invalid_pcs);
+Attrs.setInvalid();
+Diag(Attrs.getLoc(), diag::err_invalid_pcs);
 return true;
   }
   case AttributeList::AT_IntelOclBicc: CC = CC_IntelOclBicc; break;
@@ -4365,7 +4365,7 @@ bool Sema::CheckCallingConvAttr(const At
   TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC);
   if (A != TargetInfo::CCCR_OK) {
 if (A == TargetInfo::CCCR_Warning)
-  Diag(attr.getLoc(), diag::warn_cconv_ignored) << attr.getName();
+  Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs.getName();
 
 // This convention is not valid for the target. Use the default function or
 // method calling convention.
@@ -4377,7 +4377,7 @@ bool Sema::CheckCallingConvAttr(const At
 CC = Context.getDefaultCallingConvention(IsVariadic, IsCXXMethod);
   }
 
-  attr.setProcessingCache((unsigned) CC);
+  Attrs.setProcessingCache((unsigned) CC);
   return false;
 }
 
@@ -4414,10 +4414,10 @@ static bool isValidSwiftErrorResultType(
   return isValidSwiftContextType(type);
 }
 
-static void handleParameterABIAttr(Sema &S, Decl *D, const AttributeList &attr,
-   ParameterABI abi) {
-  S.AddParameterABIAttr(attr.getRange(), 

r314268 - Add test forgotten in r314262.

2017-09-26 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Sep 26 20:23:02 2017
New Revision: 314268

URL: http://llvm.org/viewvc/llvm-project?rev=314268&view=rev
Log:
Add test forgotten in r314262.

Added:
cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp   (with props)

Added: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp?rev=314268&view=auto
==
--- cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp Tue Sep 26 20:23:02 
2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck 
%s
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-DAG: @aa = external global i32, section ".sdata", align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-DAG: @bb = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}

Propchange: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/CodeGenCXX/extern-section-attribute.cpp
--
svn:mime-type = text/plain


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


[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Looks good!

I must have gotten confused with my test suggestion.
Do you have commit access, or should I commit this for you?


https://reviews.llvm.org/D37904



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: tools/clang/lib/Driver/ToolChain.cpp:394
+llvm::SmallString<8> LinkerName;
+if(Triple.isOSDarwin())
+  LinkerName.append("ld64.");

Space between `if` and `(`


Repository:
  rL LLVM

https://reviews.llvm.org/D38290



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