[PATCH] D35862: [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309081: [clang] Add ARM64 support to armintr.h for MSVC 
compatibility (authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D35862?vs=108208=108222#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35862

Files:
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/arm64intr.h
  cfe/trunk/lib/Headers/intrin.h


Index: cfe/trunk/lib/Headers/arm64intr.h
===
--- cfe/trunk/lib/Headers/arm64intr.h
+++ cfe/trunk/lib/Headers/arm64intr.h
@@ -0,0 +1,49 @@
+/*=== arm64intr.h - ARM64 Windows intrinsics 
---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+/* Only include this if we're compiling for the windows platform. */
+#ifndef _MSC_VER
+#include_next 
+#else
+
+#ifndef __ARM64INTR_H
+#define __ARM64INTR_H
+
+typedef enum
+{
+  _ARM64_BARRIER_SY= 0xF,
+  _ARM64_BARRIER_ST= 0xE,
+  _ARM64_BARRIER_LD= 0xD,
+  _ARM64_BARRIER_ISH   = 0xB,
+  _ARM64_BARRIER_ISHST = 0xA,
+  _ARM64_BARRIER_ISHLD = 0x9,
+  _ARM64_BARRIER_NSH   = 0x7,
+  _ARM64_BARRIER_NSHST = 0x6,
+  _ARM64_BARRIER_NSHLD = 0x5,
+  _ARM64_BARRIER_OSH   = 0x3,
+  _ARM64_BARRIER_OSHST = 0x2,
+  _ARM64_BARRIER_OSHLD = 0x1
+} _ARM64INTR_BARRIER_TYPE;
+
+#endif /* __ARM64INTR_H */
+#endif /* _MSC_VER */
Index: cfe/trunk/lib/Headers/intrin.h
===
--- cfe/trunk/lib/Headers/intrin.h
+++ cfe/trunk/lib/Headers/intrin.h
@@ -38,6 +38,10 @@
 #include 
 #endif
 
+#if defined(_M_ARM64)
+#include 
+#endif
+
 /* For the definition of jmp_buf. */
 #if __STDC_HOSTED__
 #include 
Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -4,6 +4,7 @@
   ammintrin.h
   arm_acle.h
   armintr.h
+  arm64intr.h
   avx2intrin.h
   avx512bwintrin.h
   avx512cdintrin.h


Index: cfe/trunk/lib/Headers/arm64intr.h
===
--- cfe/trunk/lib/Headers/arm64intr.h
+++ cfe/trunk/lib/Headers/arm64intr.h
@@ -0,0 +1,49 @@
+/*=== arm64intr.h - ARM64 Windows intrinsics ---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+/* Only include this if we're compiling for the windows platform. */
+#ifndef _MSC_VER
+#include_next 
+#else
+
+#ifndef __ARM64INTR_H
+#define __ARM64INTR_H
+
+typedef enum
+{
+  _ARM64_BARRIER_SY= 0xF,
+  _ARM64_BARRIER_ST= 0xE,
+  _ARM64_BARRIER_LD= 0xD,
+  _ARM64_BARRIER_ISH   = 0xB,
+  _ARM64_BARRIER_ISHST 

r309081 - [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Jul 25 22:29:40 2017
New Revision: 309081

URL: http://llvm.org/viewvc/llvm-project?rev=309081=rev
Log:
[clang] Add ARM64 support to armintr.h for MSVC compatibility

Summary: This fixes compiling with headers from the Windows SDK for ARM64.

Reviewers: compnerd, ruiu, mstorsjo

Reviewed By: compnerd, mstorsjo

Subscribers: mgorny, aemerson, javed.absar, kristof.beyls, llvm-commits, 
cfe-commits

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

Added:
cfe/trunk/lib/Headers/arm64intr.h
Modified:
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/intrin.h

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=309081=309080=309081=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Tue Jul 25 22:29:40 2017
@@ -4,6 +4,7 @@ set(files
   ammintrin.h
   arm_acle.h
   armintr.h
+  arm64intr.h
   avx2intrin.h
   avx512bwintrin.h
   avx512cdintrin.h

Added: cfe/trunk/lib/Headers/arm64intr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/arm64intr.h?rev=309081=auto
==
--- cfe/trunk/lib/Headers/arm64intr.h (added)
+++ cfe/trunk/lib/Headers/arm64intr.h Tue Jul 25 22:29:40 2017
@@ -0,0 +1,49 @@
+/*=== arm64intr.h - ARM64 Windows intrinsics 
---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+/* Only include this if we're compiling for the windows platform. */
+#ifndef _MSC_VER
+#include_next 
+#else
+
+#ifndef __ARM64INTR_H
+#define __ARM64INTR_H
+
+typedef enum
+{
+  _ARM64_BARRIER_SY= 0xF,
+  _ARM64_BARRIER_ST= 0xE,
+  _ARM64_BARRIER_LD= 0xD,
+  _ARM64_BARRIER_ISH   = 0xB,
+  _ARM64_BARRIER_ISHST = 0xA,
+  _ARM64_BARRIER_ISHLD = 0x9,
+  _ARM64_BARRIER_NSH   = 0x7,
+  _ARM64_BARRIER_NSHST = 0x6,
+  _ARM64_BARRIER_NSHLD = 0x5,
+  _ARM64_BARRIER_OSH   = 0x3,
+  _ARM64_BARRIER_OSHST = 0x2,
+  _ARM64_BARRIER_OSHLD = 0x1
+} _ARM64INTR_BARRIER_TYPE;
+
+#endif /* __ARM64INTR_H */
+#endif /* _MSC_VER */

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=309081=309080=309081=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Tue Jul 25 22:29:40 2017
@@ -38,6 +38,10 @@
 #include 
 #endif
 
+#if defined(_M_ARM64)
+#include 
+#endif
+
 /* For the definition of jmp_buf. */
 #if __STDC_HOSTED__
 #include 


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


[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-25 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:5625
+  // The Run-time ABI for the ARM Architecture section 4.1.2 requires
+  // AEABI-complying FP helper functions to use the base AAPCS
+  // These AEABI functions are expanded in the ARM llvm backend, all the 
builtin

Period at the end of a sentence.



Comment at: test/CodeGen/arm-float-helpers.c:32
+// Note that it is only the functions in 4.1.2 that must use the base AAPCS,
+// other runtime functions such as the _Complex helper routines are not covered
+

Ditto.



Comment at: test/CodeGen/complex-math.c:482
+  // Run-time ABI for the ARM architecture document so they must not always
+  // use the base AAPCS
+

Ditto.


https://reviews.llvm.org/D35538



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


[PATCH] D35862: [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Patch updated as per comments.


https://reviews.llvm.org/D35862



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


[PATCH] D35862: [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 108208.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D35862

Files:
  lib/Headers/CMakeLists.txt
  lib/Headers/arm64intr.h
  lib/Headers/intrin.h


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -38,6 +38,10 @@
 #include 
 #endif
 
+#if defined(_M_ARM64)
+#include 
+#endif
+
 /* For the definition of jmp_buf. */
 #if __STDC_HOSTED__
 #include 
Index: lib/Headers/arm64intr.h
===
--- /dev/null
+++ lib/Headers/arm64intr.h
@@ -0,0 +1,49 @@
+/*=== arm64intr.h - ARM64 Windows intrinsics 
---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+/* Only include this if we're compiling for the windows platform. */
+#ifndef _MSC_VER
+#include_next 
+#else
+
+#ifndef __ARM64INTR_H
+#define __ARM64INTR_H
+
+typedef enum
+{
+  _ARM64_BARRIER_SY= 0xF,
+  _ARM64_BARRIER_ST= 0xE,
+  _ARM64_BARRIER_LD= 0xD,
+  _ARM64_BARRIER_ISH   = 0xB,
+  _ARM64_BARRIER_ISHST = 0xA,
+  _ARM64_BARRIER_ISHLD = 0x9,
+  _ARM64_BARRIER_NSH   = 0x7,
+  _ARM64_BARRIER_NSHST = 0x6,
+  _ARM64_BARRIER_NSHLD = 0x5,
+  _ARM64_BARRIER_OSH   = 0x3,
+  _ARM64_BARRIER_OSHST = 0x2,
+  _ARM64_BARRIER_OSHLD = 0x1
+} _ARM64INTR_BARRIER_TYPE;
+
+#endif /* __ARM64INTR_H */
+#endif /* _MSC_VER */
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -4,6 +4,7 @@
   ammintrin.h
   arm_acle.h
   armintr.h
+  arm64intr.h
   avx2intrin.h
   avx512bwintrin.h
   avx512cdintrin.h


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -38,6 +38,10 @@
 #include 
 #endif
 
+#if defined(_M_ARM64)
+#include 
+#endif
+
 /* For the definition of jmp_buf. */
 #if __STDC_HOSTED__
 #include 
Index: lib/Headers/arm64intr.h
===
--- /dev/null
+++ lib/Headers/arm64intr.h
@@ -0,0 +1,49 @@
+/*=== arm64intr.h - ARM64 Windows intrinsics ---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+/* Only include this if we're compiling for the windows platform. */
+#ifndef _MSC_VER
+#include_next 
+#else
+
+#ifndef __ARM64INTR_H
+#define __ARM64INTR_H
+
+typedef enum
+{
+  _ARM64_BARRIER_SY= 0xF,
+  _ARM64_BARRIER_ST= 0xE,
+  _ARM64_BARRIER_LD= 0xD,
+  _ARM64_BARRIER_ISH   = 0xB,
+  _ARM64_BARRIER_ISHST = 0xA,
+  _ARM64_BARRIER_ISHLD = 0x9,
+  _ARM64_BARRIER_NSH   = 0x7,
+  

[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-25 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I think that the approach is reasonable.  However, the test needs tweaking.  
The function and the call both are ambiguous in the match.  Can you match the 
call sequence?  Or explicitly the local label and then the call.


https://reviews.llvm.org/D35538



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


[PATCH] D35862: [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Please split this out into `arm64intr.h` and include it from `intrin.h` under a 
`#if defined(_M_ARM64)` case before committing.


https://reviews.llvm.org/D35862



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


[PATCH] D35862: [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

The Microsoft version of `intrin.h` includes a header named `arm64intr.h` 
(IIRC), I think it'd be better for compatibility if we also provided a file 
with the same name instead of reusing this one.


https://reviews.llvm.org/D35862



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


[PATCH] D35746: Make new PM honor -fdebug-info-for-profiling (clang side)

2017-07-25 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:843
 
   PGOOptions PGOOpt;
 

Maybe make this an optional to avoid the big predicate below?



Comment at: lib/CodeGen/BackendUtil.cpp:847-859
   if (PGOOpt.RunProfileGen)
 PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ?
   DefaultProfileGenName : CodeGenOpts.InstrProfileOutput;
 
   // -fprofile-use.
   if (CodeGenOpts.hasProfileIRUse())
 PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;

At least some of these seem mutually exclusive, so show that with `else if`?

I wonder, are all of these mutually exclusive?


https://reviews.llvm.org/D35746



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


[PATCH] D35718: [clang-tidy] Do not issue fixit for explicit template specializations

2017-07-25 Thread Felix Berger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309067: [clang-tidy] Do not issue fixit for explicit 
template specializations (authored by flx).

Changed prior to commit:
  https://reviews.llvm.org/D35718?vs=107786=108193#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35718

Files:
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -58,6 +58,18 @@
   return Matches.empty();
 }
 
+bool isExplicitTemplateSpecialization(const FunctionDecl ) {
+  if (const auto *SpecializationInfo = 
Function.getTemplateSpecializationInfo())
+if (SpecializationInfo->getTemplateSpecializationKind() ==
+TSK_ExplicitSpecialization)
+  return true;
+  if (const auto *Method = llvm::dyn_cast())
+if (Method->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization &&
+Method->getMemberSpecializationInfo()->isExplicitSpecialization())
+  return true;
+  return false;
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -133,9 +145,11 @@
   // 2. the function is virtual as it might break overrides
   // 3. the function is referenced outside of a call expression within the
   //compilation unit as the signature change could introduce build errors.
+  // 4. the function is an explicit template specialization.
   const auto *Method = llvm::dyn_cast(Function);
   if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()) ||
-  isReferencedOutsideOfCallExpr(*Function, *Result.Context))
+  isReferencedOutsideOfCallExpr(*Function, *Result.Context) ||
+  isExplicitTemplateSpecialization(*Function))
 return;
   for (const auto *FunctionDecl = Function; FunctionDecl != nullptr;
FunctionDecl = FunctionDecl->getPreviousDecl()) {
Index: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -348,3 +348,14 @@
   ExpensiveToCopyType E;
   NegativeUsingConstructor S(E);
 }
+
+template
+void templateFunction(T) {
+}
+
+template<>
+void templateFunction(ExpensiveToCopyType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:64: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void 
templateFunction(ExpensiveToCopyType E) {
+  E.constReference();
+}


Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -58,6 +58,18 @@
   return Matches.empty();
 }
 
+bool isExplicitTemplateSpecialization(const FunctionDecl ) {
+  if (const auto *SpecializationInfo = Function.getTemplateSpecializationInfo())
+if (SpecializationInfo->getTemplateSpecializationKind() ==
+TSK_ExplicitSpecialization)
+  return true;
+  if (const auto *Method = llvm::dyn_cast())
+if (Method->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization &&
+Method->getMemberSpecializationInfo()->isExplicitSpecialization())
+  return true;
+  return false;
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -133,9 +145,11 @@
   // 2. the function is virtual as it might break overrides
   // 3. the function is referenced outside of a call expression within the
   //compilation unit as the signature change could introduce build errors.
+  // 4. the function is an explicit template specialization.
   const auto *Method = llvm::dyn_cast(Function);
   if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()) ||
-  isReferencedOutsideOfCallExpr(*Function, *Result.Context))
+  isReferencedOutsideOfCallExpr(*Function, *Result.Context) ||
+  isExplicitTemplateSpecialization(*Function))
 return;
   for (const auto *FunctionDecl = Function; FunctionDecl != nullptr;
FunctionDecl = FunctionDecl->getPreviousDecl()) {
Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -348,3 +348,14 @@
   ExpensiveToCopyType E;
   

[clang-tools-extra] r309067 - [clang-tidy] Do not issue fixit for explicit template specializations

2017-07-25 Thread Felix Berger via cfe-commits
Author: flx
Date: Tue Jul 25 17:45:41 2017
New Revision: 309067

URL: http://llvm.org/viewvc/llvm-project?rev=309067=rev
Log:
[clang-tidy] Do not issue fixit for explicit template specializations

Summary:

Do not issue fixit in UnnecessaryValueParamCheck if the function is an explicit 
template specialization as this could cause build breakages.

Reviewers: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=309067=309066=309067=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Tue Jul 25 17:45:41 2017
@@ -58,6 +58,18 @@ bool hasLoopStmtAncestor(const DeclRefEx
   return Matches.empty();
 }
 
+bool isExplicitTemplateSpecialization(const FunctionDecl ) {
+  if (const auto *SpecializationInfo = 
Function.getTemplateSpecializationInfo())
+if (SpecializationInfo->getTemplateSpecializationKind() ==
+TSK_ExplicitSpecialization)
+  return true;
+  if (const auto *Method = llvm::dyn_cast())
+if (Method->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization &&
+Method->getMemberSpecializationInfo()->isExplicitSpecialization())
+  return true;
+  return false;
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -133,9 +145,11 @@ void UnnecessaryValueParamCheck::check(c
   // 2. the function is virtual as it might break overrides
   // 3. the function is referenced outside of a call expression within the
   //compilation unit as the signature change could introduce build errors.
+  // 4. the function is an explicit template specialization.
   const auto *Method = llvm::dyn_cast(Function);
   if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()) ||
-  isReferencedOutsideOfCallExpr(*Function, *Result.Context))
+  isReferencedOutsideOfCallExpr(*Function, *Result.Context) ||
+  isExplicitTemplateSpecialization(*Function))
 return;
   for (const auto *FunctionDecl = Function; FunctionDecl != nullptr;
FunctionDecl = FunctionDecl->getPreviousDecl()) {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=309067=309066=309067=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
Tue Jul 25 17:45:41 2017
@@ -348,3 +348,14 @@ void fun() {
   ExpensiveToCopyType E;
   NegativeUsingConstructor S(E);
 }
+
+template
+void templateFunction(T) {
+}
+
+template<>
+void templateFunction(ExpensiveToCopyType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:64: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void 
templateFunction(ExpensiveToCopyType E) {
+  E.constReference();
+}


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


r309061 - [StaticAnalyzer] LoopUnrolling - Attempt #2 to fix a crash in r309006.

2017-07-25 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Tue Jul 25 16:49:16 2017
New Revision: 309061

URL: http://llvm.org/viewvc/llvm-project?rev=309061=rev
Log:
[StaticAnalyzer] LoopUnrolling - Attempt #2 to fix a crash in r309006.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp?rev=309061=309060=309061=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp Tue Jul 25 16:49:16 2017
@@ -183,9 +183,9 @@ bool isUnrolledLoopBlock(const CFGBlock
 LBV.setBlocksOfLoop(E.first, M);
 // In case of an inlined function call check if any of its callSiteBlock is
 // marked.
-while (BlockSet.find(SearchedBlock) == BlockSet.end() && 
!StackFrame->inTopFrame()) {
+while (BlockSet.find(SearchedBlock) == BlockSet.end() && StackFrame) {
   SearchedBlock = StackFrame->getCallSiteBlock();
-  if(!SearchedBlock)
+  if(!SearchedBlock || StackFrame->inTopFrame())
 break;
   StackFrame = StackFrame->getParent()->getCurrentStackFrame();
 }


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


Re: r309058 - [CodeGen] Correctly model std::byte's aliasing properties

2017-07-25 Thread David Majnemer via cfe-commits
Should this go into 5.0 ?

On Tue, Jul 25, 2017 at 4:33 PM, David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: majnemer
> Date: Tue Jul 25 16:33:58 2017
> New Revision: 309058
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309058=rev
> Log:
> [CodeGen] Correctly model std::byte's aliasing properties
>
> std::byte, when defined as an enum, needs to be given special treatment
> with regards to its aliasing properties. An array of std::byte is
> allowed to be used as storage for other types.
>
> This fixes PR33916.
>
> Differential Revision: https://reviews.llvm.org/D35824
>
> Added:
> cfe/trunk/test/CodeGenCXX/std-byte.cpp
> Modified:
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/lib/AST/Type.cpp
> cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Type.h?rev=309058=309057=309058=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Tue Jul 25 16:33:58 2017
> @@ -1752,6 +1752,7 @@ public:
>bool isTemplateTypeParmType() const;  // C++ template type
> parameter
>bool isNullPtrType() const;   // C++11 std::nullptr_t
>bool isAlignValT() const; // C++17 std::align_val_t
> +  bool isStdByteType() const;   // C++17 std::byte
>bool isAtomicType() const;// C11 _Atomic()
>
>  #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
>
> Modified: cfe/trunk/lib/AST/Type.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> Type.cpp?rev=309058=309057=309058=diff
> 
> ==
> --- cfe/trunk/lib/AST/Type.cpp (original)
> +++ cfe/trunk/lib/AST/Type.cpp Tue Jul 25 16:33:58 2017
> @@ -2313,6 +2313,15 @@ bool Type::isAlignValT() const {
>return false;
>  }
>
> +bool Type::isStdByteType() const {
> +  if (auto *ET = getAs()) {
> +auto *II = ET->getDecl()->getIdentifier();
> +if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
> +  return true;
> +  }
> +  return false;
> +}
> +
>  bool Type::isPromotableIntegerType() const {
>if (const BuiltinType *BT = getAs())
>  switch (BT->getKind()) {
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenTBAA.cpp?rev=309058=309057=309058=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Tue Jul 25 16:33:58 2017
> @@ -139,6 +139,12 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
>  }
>}
>
> +  // C++1z [basic.lval]p10: "If a program attempts to access the stored
> value of
> +  // an object through a glvalue of other than one of the following types
> the
> +  // behavior is undefined: [...] a char, unsigned char, or std::byte
> type."
> +  if (Ty->isStdByteType())
> +return MetadataCache[Ty] = getChar();
> +
>// Handle pointers.
>// TODO: Implement C++'s type "similarity" and consider dis-"similar"
>// pointers distinct.
>
> Added: cfe/trunk/test/CodeGenCXX/std-byte.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/std-byte.cpp?rev=309058=auto
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/std-byte.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/std-byte.cpp Tue Jul 25 16:33:58 2017
> @@ -0,0 +1,41 @@
> +// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown
> -emit-llvm -O1 -disable-llvm-passes -o - %s | FileCheck %s
> +
> +// std::byte should be considered equivalent to char for aliasing.
> +
> +namespace std {
> +enum byte : unsigned char {};
> +}
> +
> +// CHECK-LABEL: define void @test0(
> +extern "C" void test0(std::byte *sb, int *i) {
> +  // CHECK: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR:!.*]]
> +  *sb = std::byte{0};
> +
> +  // CHECK: store i32 1, i32* %{{.*}} !tbaa [[TAG_INT:!.*]]
> +  *i = 1;
> +}
> +
> +enum byte : unsigned char {};
> +namespace my {
> +enum byte : unsigned char {};
> +namespace std {
> +enum byte : unsigned char {};
> +} // namespace std
> +} // namespace my
> +
> +// Make sure we don't get confused with other enums named 'byte'.
> +
> +// CHECK-LABEL: define void @test1(
> +extern "C" void test1(::byte *b, ::my::byte *mb, ::my::std::byte *msb) {
> +  *b = ::byte{0};
> +  *mb = ::my::byte{0};
> +  *msb = ::my::std::byte{0};
> +  // CHECK-NOT: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR]]
> +}
> +
> +// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
> +// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
> +// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
> +// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], 

[PATCH] D35824: [Sema] Implicitly apply the may_alias attribute to std::byte

2017-07-25 Thread David Majnemer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309058: [CodeGen] Correctly model std::byte's aliasing 
properties (authored by majnemer).

Changed prior to commit:
  https://reviews.llvm.org/D35824?vs=108166=108185#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35824

Files:
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
  cfe/trunk/test/CodeGenCXX/std-byte.cpp


Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
@@ -139,6 +139,12 @@
 }
   }
 
+  // C++1z [basic.lval]p10: "If a program attempts to access the stored value 
of
+  // an object through a glvalue of other than one of the following types the
+  // behavior is undefined: [...] a char, unsigned char, or std::byte type."
+  if (Ty->isStdByteType())
+return MetadataCache[Ty] = getChar();
+
   // Handle pointers.
   // TODO: Implement C++'s type "similarity" and consider dis-"similar"
   // pointers distinct.
Index: cfe/trunk/lib/AST/Type.cpp
===
--- cfe/trunk/lib/AST/Type.cpp
+++ cfe/trunk/lib/AST/Type.cpp
@@ -2313,6 +2313,15 @@
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+  return true;
+  }
+  return false;
+}
+
 bool Type::isPromotableIntegerType() const {
   if (const BuiltinType *BT = getAs())
 switch (BT->getKind()) {
Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -1752,6 +1752,7 @@
   bool isTemplateTypeParmType() const;  // C++ template type parameter
   bool isNullPtrType() const;   // C++11 std::nullptr_t
   bool isAlignValT() const; // C++17 std::align_val_t
+  bool isStdByteType() const;   // C++17 std::byte
   bool isAtomicType() const;// C11 _Atomic()
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
Index: cfe/trunk/test/CodeGenCXX/std-byte.cpp
===
--- cfe/trunk/test/CodeGenCXX/std-byte.cpp
+++ cfe/trunk/test/CodeGenCXX/std-byte.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm 
-O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+// CHECK-LABEL: define void @test0(
+extern "C" void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}} !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+enum byte : unsigned char {};
+namespace my {
+enum byte : unsigned char {};
+namespace std {
+enum byte : unsigned char {};
+} // namespace std
+} // namespace my
+
+// Make sure we don't get confused with other enums named 'byte'.
+
+// CHECK-LABEL: define void @test1(
+extern "C" void test1(::byte *b, ::my::byte *mb, ::my::std::byte *msb) {
+  *b = ::byte{0};
+  *mb = ::my::byte{0};
+  *msb = ::my::std::byte{0};
+  // CHECK-NOT: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR]]
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]


Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
@@ -139,6 +139,12 @@
 }
   }
 
+  // C++1z [basic.lval]p10: "If a program attempts to access the stored value of
+  // an object through a glvalue of other than one of the following types the
+  // behavior is undefined: [...] a char, unsigned char, or std::byte type."
+  if (Ty->isStdByteType())
+return MetadataCache[Ty] = getChar();
+
   // Handle pointers.
   // TODO: Implement C++'s type "similarity" and consider dis-"similar"
   // pointers distinct.
Index: cfe/trunk/lib/AST/Type.cpp
===
--- cfe/trunk/lib/AST/Type.cpp
+++ cfe/trunk/lib/AST/Type.cpp
@@ -2313,6 +2313,15 @@
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+  return true;
+  }
+  return false;

r309058 - [CodeGen] Correctly model std::byte's aliasing properties

2017-07-25 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Jul 25 16:33:58 2017
New Revision: 309058

URL: http://llvm.org/viewvc/llvm-project?rev=309058=rev
Log:
[CodeGen] Correctly model std::byte's aliasing properties

std::byte, when defined as an enum, needs to be given special treatment
with regards to its aliasing properties. An array of std::byte is
allowed to be used as storage for other types.

This fixes PR33916.

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

Added:
cfe/trunk/test/CodeGenCXX/std-byte.cpp
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=309058=309057=309058=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Jul 25 16:33:58 2017
@@ -1752,6 +1752,7 @@ public:
   bool isTemplateTypeParmType() const;  // C++ template type parameter
   bool isNullPtrType() const;   // C++11 std::nullptr_t
   bool isAlignValT() const; // C++17 std::align_val_t
+  bool isStdByteType() const;   // C++17 std::byte
   bool isAtomicType() const;// C11 _Atomic()
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=309058=309057=309058=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Jul 25 16:33:58 2017
@@ -2313,6 +2313,15 @@ bool Type::isAlignValT() const {
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+  return true;
+  }
+  return false;
+}
+
 bool Type::isPromotableIntegerType() const {
   if (const BuiltinType *BT = getAs())
 switch (BT->getKind()) {

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=309058=309057=309058=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Tue Jul 25 16:33:58 2017
@@ -139,6 +139,12 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
 }
   }
 
+  // C++1z [basic.lval]p10: "If a program attempts to access the stored value 
of
+  // an object through a glvalue of other than one of the following types the
+  // behavior is undefined: [...] a char, unsigned char, or std::byte type."
+  if (Ty->isStdByteType())
+return MetadataCache[Ty] = getChar();
+
   // Handle pointers.
   // TODO: Implement C++'s type "similarity" and consider dis-"similar"
   // pointers distinct.

Added: cfe/trunk/test/CodeGenCXX/std-byte.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/std-byte.cpp?rev=309058=auto
==
--- cfe/trunk/test/CodeGenCXX/std-byte.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/std-byte.cpp Tue Jul 25 16:33:58 2017
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm 
-O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+// CHECK-LABEL: define void @test0(
+extern "C" void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}} !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+enum byte : unsigned char {};
+namespace my {
+enum byte : unsigned char {};
+namespace std {
+enum byte : unsigned char {};
+} // namespace std
+} // namespace my
+
+// Make sure we don't get confused with other enums named 'byte'.
+
+// CHECK-LABEL: define void @test1(
+extern "C" void test1(::byte *b, ::my::byte *mb, ::my::std::byte *msb) {
+  *b = ::byte{0};
+  *mb = ::my::byte{0};
+  *msb = ::my::std::byte{0};
+  // CHECK-NOT: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR]]
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]


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


r309054 - Reorder tests to match latest SD-6 draft.

2017-07-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 25 16:31:42 2017
New Revision: 309054

URL: http://llvm.org/viewvc/llvm-project?rev=309054=rev
Log:
Reorder tests to match latest SD-6 draft.

Modified:
cfe/trunk/test/Lexer/cxx-features.cpp

Modified: cfe/trunk/test/Lexer/cxx-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=309054=309053=309054=diff
==
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)
+++ cfe/trunk/test/Lexer/cxx-features.cpp Tue Jul 25 16:31:42 2017
@@ -22,10 +22,6 @@
 
 // --- C++17 features ---
 
-#if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name
-#error "wrong value for __cpp_variadic_using"
-#endif
-
 #if check(hex_float, 0, 0, 0, 201603)
 #error "wrong value for __cpp_hex_float"
 #endif
@@ -60,6 +56,10 @@
 
 // static_assert checked below
 
+#if check(deduction_guides, 0, 0, 0, 201611) // FIXME: provisional name
+#error "wrong value for __cpp_deduction_guides"
+#endif
+
 #if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name
 #error "wrong value for __cpp_template_auto"
 #endif
@@ -80,6 +80,10 @@
 
 // inheriting_constructors checked below
 
+#if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name
+#error "wrong value for __cpp_variadic_using"
+#endif
+
 #if check(aggregate_bases, 0, 0, 0, 201603)
 #error "wrong value for __cpp_aggregate_bases"
 #endif
@@ -96,10 +100,6 @@
 #error "wrong value for __cpp_template_template_args"
 #endif
 
-#if check(deduction_guides, 0, 0, 0, 201611) // FIXME: provisional name
-#error "wrong value for __cpp_deduction_guides"
-#endif
-
 // --- C++14 features ---
 
 #if check(binary_literals, 0, 0, 201304, 201304)


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


[PATCH] D35824: [Sema] Implicitly apply the may_alias attribute to std::byte

2017-07-25 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM with a tweaked comment. Thanks!




Comment at: lib/CodeGen/CodeGenTBAA.cpp:88-90
+  // C++1z [intro.object]p3: If a complete object is created in storage
+  // associated with another object e of type [...] "array of N std::byte", 
that
+  // array provides storage for the created object [...].

[basic.lval]p10: "If a program attempts to access the stored value of an object 
through a glvalue of other than one of the following types the behavior is 
undefined: [...] a char, unsigned char, or std::byte type."

... is the relevant quotation for the purpose of aliasing.


https://reviews.llvm.org/D35824



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


r309052 - clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h: Add a forward decl AnalysisManager, to unbreak modules build.

2017-07-25 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Jul 25 16:23:17 2017
New Revision: 309052

URL: http://llvm.org/viewvc/llvm-project?rev=309052=rev
Log:
clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h: Add a forward decl 
AnalysisManager, to unbreak modules build.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h?rev=309052=309051=309052=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
Tue Jul 25 16:23:17 2017
@@ -22,6 +22,8 @@
 
 namespace clang {
 namespace ento {
+class AnalysisManager;
+
 ProgramStateRef markLoopAsUnrolled(const Stmt *Term, ProgramStateRef State,
const FunctionDecl *FD);
 bool isUnrolledLoopBlock(const CFGBlock *Block, ExplodedNode *Pred,


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


Re: r309036 - [StaticAnalyzer] LoopUnrolling - Attempt to fix a crash in r309006.

2017-07-25 Thread Kostya Serebryany via cfe-commits
Looks like one more failure (this time under ubsan) remains in this code
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6708/steps/check-clang%20ubsan/logs/stdio
Please fix asap.

/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:188:45:
runtime error: member call on null pointer of type
'clang::LocationContext'
#0 0x6aa767d in clang::ento::isUnrolledLoopBlock(clang::CFGBlock
const*, clang::ento::ExplodedNode*, clang::ento::AnalysisManager&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:188:45
#1 0x6a651ed in
clang::ento::ExprEngine::processCFGBlockEntrance(clang::BlockEdge
const&, clang::ento::NodeBuilderWithSinks&,
clang::ento::ExplodedNode*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1519:9
#2 0x6a401a0 in
clang::ento::CoreEngine::HandleBlockEdge(clang::BlockEdge const&,
clang::ento::ExplodedNode*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:334:10
#3 0x6a3fd33 in
clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*,
clang::ProgramPoint, clang::ento::WorkListUnit const&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:246:7
#4 0x6a3f97b in
clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext
const*, unsigned int,
llvm::IntrusiveRefCntPtr)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:235:5
#5 0x53edd9e in
clang::ento::ExprEngine::ExecuteWorkList(clang::LocationContext
const*, unsigned int)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:109:19
#6 0x539ac8e in (anonymous
namespace)::AnalysisConsumer::ActionExprEngine(clang::Decl*, bool,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet >*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:717:7
#7 0x539a478 in (anonymous
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int,
clang::ento::ExprEngine::InliningModes, llvm::DenseSet >*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:685:5
#8 0x538e22d in (anonymous
namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:498:5
#9 0x538bb29 in (anonymous
namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:550:7
#10 0x5462b99 in clang::ParseAST(clang::Sema&, bool, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:159:13
#11 0x3fc98f2 in clang::FrontendAction::Execute()
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:902:8
#12 0x3f57d74 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:980:11
#13 0x415a1ac in
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:251:25
#14 0xe8a5fe in cc1_main(llvm::ArrayRef, char const*,
void*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/driver/cc1_main.cpp:221:13
#15 0xe7ca13 in ExecuteCC1Tool(llvm::ArrayRef,
llvm::StringRef)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/cla


On Tue, Jul 25, 2017 at 2:54 PM, Peter Szecsi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: szepet
> Date: Tue Jul 25 14:54:58 2017
> New Revision: 309036
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309036=rev
> Log:
> [StaticAnalyzer] LoopUnrolling - Attempt to fix a crash in r309006.
>
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> StaticAnalyzer/Core/LoopUnrolling.cpp?rev=309036&
> r1=309035=309036=diff
> 
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp Tue Jul 25
> 14:54:58 2017
> @@ -183,8 +183,10 @@ bool isUnrolledLoopBlock(const CFGBlock
>  

r309049 - [clang] Add abi-breaking-checks support to clang

2017-07-25 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Jul 25 16:00:02 2017
New Revision: 309049

URL: http://llvm.org/viewvc/llvm-project?rev=309049=rev
Log:
[clang] Add abi-breaking-checks support to clang

Summary: You can now use REQUIRES:abi-breaking-checks in clang too

Reviewers: chapuni, probinson, ddunbar, jroelofs

Reviewed By: jroelofs

Subscribers: jroelofs, cfe-commits

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

Modified:
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=309049=309048=309049=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Tue Jul 25 16:00:02 2017
@@ -532,3 +532,6 @@ lit.util.usePlatformSdkOnDarwin(config,
 macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
 if macOSSDKVersion is not None:
 config.available_features.add('macos-sdk-' + macOSSDKVersion)
+
+if config.enable_abi_breaking_checks == "1":
+config.available_features.add('abi-breaking-checks')

Modified: cfe/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.in?rev=309049=309048=309049=diff
==
--- cfe/trunk/test/lit.site.cfg.in (original)
+++ cfe/trunk/test/lit.site.cfg.in Tue Jul 25 16:00:02 2017
@@ -24,6 +24,7 @@ config.clang_examples = @CLANG_BUILD_EXA
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
+config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.


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


[PATCH] D35426: [clang] Add abi-breaking-checks support to clang

2017-07-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309049: [clang] Add abi-breaking-checks support to clang 
(authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D35426?vs=106671=108180#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35426

Files:
  cfe/trunk/test/lit.cfg
  cfe/trunk/test/lit.site.cfg.in


Index: cfe/trunk/test/lit.site.cfg.in
===
--- cfe/trunk/test/lit.site.cfg.in
+++ cfe/trunk/test/lit.site.cfg.in
@@ -24,6 +24,7 @@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
+config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: cfe/trunk/test/lit.cfg
===
--- cfe/trunk/test/lit.cfg
+++ cfe/trunk/test/lit.cfg
@@ -532,3 +532,6 @@
 macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
 if macOSSDKVersion is not None:
 config.available_features.add('macos-sdk-' + macOSSDKVersion)
+
+if config.enable_abi_breaking_checks == "1":
+config.available_features.add('abi-breaking-checks')


Index: cfe/trunk/test/lit.site.cfg.in
===
--- cfe/trunk/test/lit.site.cfg.in
+++ cfe/trunk/test/lit.site.cfg.in
@@ -24,6 +24,7 @@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
+config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: cfe/trunk/test/lit.cfg
===
--- cfe/trunk/test/lit.cfg
+++ cfe/trunk/test/lit.cfg
@@ -532,3 +532,6 @@
 macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
 if macOSSDKVersion is not None:
 config.available_features.add('macos-sdk-' + macOSSDKVersion)
+
+if config.enable_abi_breaking_checks == "1":
+config.available_features.add('abi-breaking-checks')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35862: [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Refer 
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf 
for memory barriers.


https://reviews.llvm.org/D35862



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


[PATCH] D35863: Use the allocator's pointers for deallocation in `std::list`

2017-07-25 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.

`pointer_traits::to_pointer(r)` is not required to return a deallocatable 
pointer; indeed generally it *cannot* determine a deallocatable representation 
without help from the allocator. Therefore, we must not rely on representations 
derived from `to_pointer` when deallocating; we must pass to `deallocate` the 
exact same pointer (or at least a pointer linearly derived from the pointer) 
that we originally received from `allocate`.

I have an example fancy-pointer allocator here which might be convertible into 
a test case:
https://github.com/Quuxplusone/from-scratch/blob/master/include/scratch/bits/containers/segmented-allocator.h


https://reviews.llvm.org/D35863

Files:
  include/list

Index: include/list
===
--- include/list
+++ include/list
@@ -728,7 +728,7 @@
 __sz() = 0;
 while (__f != __l)
 {
-__node_pointer __np = __f->__as_node();
+__node_pointer __np = static_cast<__node_pointer>(__f);
 __f = __f->__next_;
 __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
 __node_alloc_traits::deallocate(__na, __np, 1);
@@ -1389,10 +1389,12 @@
 #endif
 __node_allocator& __na = base::__node_alloc();
 typedef __allocator_destructor<__node_allocator> _Dp;
-unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
+__node_pointer __np = __node_alloc_traits::allocate(__na, 1);
+unique_ptr<__node, _Dp> __hold(__np, _Dp(__na, 1));
 __hold->__prev_ = 0;
 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
-__link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
+__link_pointer __nl = static_cast<__link_pointer>(__np);
+__link_nodes(__p.__ptr_, __nl, __nl);
 ++base::__sz();
 #if _LIBCPP_DEBUG_LEVEL >= 2
 return iterator(__hold.release()->__as_link(), this);
@@ -1418,26 +1420,29 @@
 size_type __ds = 0;
 __node_allocator& __na = base::__node_alloc();
 typedef __allocator_destructor<__node_allocator> _Dp;
-unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
+__node_pointer __np = __node_alloc_traits::allocate(__na, 1);
+unique_ptr<__node, _Dp> __hold(__np, _Dp(__na, 1));
 __hold->__prev_ = 0;
 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
 ++__ds;
+__link_pointer __nl = static_cast<__link_pointer>(__np);
+__hold.release();
 #if _LIBCPP_DEBUG_LEVEL >= 2
-__r = iterator(__hold->__as_link(), this);
+iterator __r = iterator(__nl, this);
 #else
-__r = iterator(__hold->__as_link());
+iterator __r = iterator(__nl);
 #endif
-__hold.release();
 iterator __e = __r;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 for (--__n; __n != 0; --__n, ++__e, ++__ds)
 {
-__hold.reset(__node_alloc_traits::allocate(__na, 1));
+__np = __node_alloc_traits::allocate(__na, 1);
+__hold.reset(__np);
 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
-__e.__ptr_->__next_ = __hold->__as_link();
+__e.__ptr_->__next_ = __np;
 __hold->__prev_ = __e.__ptr_;
 __hold.release();
 }
@@ -1449,7 +1454,7 @@
 {
 __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
 __link_pointer __prev = __e.__ptr_->__prev_;
-__node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
+__node_alloc_traits::deallocate(__na, static_cast<__node_pointer>(__e.__ptr_), 1);
 if (__prev == 0)
 break;
 #if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1486,26 +1491,29 @@
 size_type __ds = 0;
 __node_allocator& __na = base::__node_alloc();
 typedef __allocator_destructor<__node_allocator> _Dp;
-unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
+__node_pointer __np = __node_alloc_traits::allocate(__na, 1);
+unique_ptr<__node, _Dp> __hold(__np, _Dp(__na, 1));
 __hold->__prev_ = 0;
 __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
 ++__ds;
+__link_pointer __nl = static_cast<__link_pointer>(__np);
+__hold.release();
 #if _LIBCPP_DEBUG_LEVEL >= 2
-__r = iterator(__hold.get()->__as_link(), this);
+iterator __r = iterator(__nl, this);
 #else
-__r = iterator(__hold.get()->__as_link());
+iterator __r = iterator(__nl);
 #endif
-__hold.release();
 iterator __e = __r;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // 

[PATCH] D35862: [clang] Add ARM64 support to armintr.h for MSVC compatibility

2017-07-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

This fixes compiling with headers from the Windows SDK for ARM64.


https://reviews.llvm.org/D35862

Files:
  lib/Headers/armintr.h


Index: lib/Headers/armintr.h
===
--- lib/Headers/armintr.h
+++ lib/Headers/armintr.h
@@ -41,5 +41,21 @@
   _ARM_BARRIER_OSHST = 0x2
 } _ARMINTR_BARRIER_TYPE;
 
+typedef enum
+{
+  _ARM64_BARRIER_SY= 0xF,
+  _ARM64_BARRIER_ST= 0xE,
+  _ARM64_BARRIER_LD= 0xD,
+  _ARM64_BARRIER_ISH   = 0xB,
+  _ARM64_BARRIER_ISHST = 0xA,
+  _ARM64_BARRIER_ISHLD = 0x9,
+  _ARM64_BARRIER_NSH   = 0x7,
+  _ARM64_BARRIER_NSHST = 0x6,
+  _ARM64_BARRIER_NSHLD = 0x5,
+  _ARM64_BARRIER_OSH   = 0x3,
+  _ARM64_BARRIER_OSHST = 0x2,
+  _ARM64_BARRIER_OSHLD = 0x1
+} _ARM64INTR_BARRIER_TYPE;
+
 #endif /* __ARMINTR_H */
 #endif /* _MSC_VER */


Index: lib/Headers/armintr.h
===
--- lib/Headers/armintr.h
+++ lib/Headers/armintr.h
@@ -41,5 +41,21 @@
   _ARM_BARRIER_OSHST = 0x2
 } _ARMINTR_BARRIER_TYPE;
 
+typedef enum
+{
+  _ARM64_BARRIER_SY= 0xF,
+  _ARM64_BARRIER_ST= 0xE,
+  _ARM64_BARRIER_LD= 0xD,
+  _ARM64_BARRIER_ISH   = 0xB,
+  _ARM64_BARRIER_ISHST = 0xA,
+  _ARM64_BARRIER_ISHLD = 0x9,
+  _ARM64_BARRIER_NSH   = 0x7,
+  _ARM64_BARRIER_NSHST = 0x6,
+  _ARM64_BARRIER_NSHLD = 0x5,
+  _ARM64_BARRIER_OSH   = 0x3,
+  _ARM64_BARRIER_OSHST = 0x2,
+  _ARM64_BARRIER_OSHLD = 0x1
+} _ARM64INTR_BARRIER_TYPE;
+
 #endif /* __ARMINTR_H */
 #endif /* _MSC_VER */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: include/clang/Basic/Builtins.def:717
+ATOMIC_BUILTIN(__opencl_atomic_fetch_max, "v.", "t")
+
 #undef ATOMIC_BUILTIN

Will the OpenCL 2.0 memory fences also be supported which also have a memory 
order and memory scope?



Comment at: include/clang/Basic/SyncScope.h:25-29
+  SingleThread  = 0,
+  WorkGroup = 1,
+  Device= 2,
+  System= 3,
+  SubGroup  = 4,

Since the builtins are being named as __opencl then should these also be named 
as opencl_ since they are the memory scopes for OpenCL using the OpenCL numeric 
values?

If another language wants to use memory scopes, would it then add its own 
langx_* names in a similar way that is done for address spaces where the LangAS 
enumeration type has values for each distinct language. Each target is then 
responsible for mapping each language scope to the appropriate target specific 
scope as is done for address spaces?

If so then the builtins are really supporting the concept of memory scopes and 
are not language specific as this enumeration can support multiple languages in 
the same way as the LangAS enumeration supports multiple languages. If so the 
builtins would be better named to reflect this as @b-sumner suggested.


https://reviews.llvm.org/D28691



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


[PATCH] D35746: Make new PM honor -fdebug-info-for-profiling (clang side)

2017-07-25 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 108174.
danielcdh added a comment.

update


https://reviews.llvm.org/D35746

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -855,10 +855,13 @@
   if (!CodeGenOpts.SampleProfileFile.empty())
 PGOOpt.SampleProfileFile = CodeGenOpts.SampleProfileFile;
 
+  if (CodeGenOpts.DebugInfoForProfiling)
+PGOOpt.SampleProfileGen = true;
+
   // Only pass a PGO options struct if -fprofile-generate or
   // -fprofile-use were passed on the cmdline.
   PassBuilder PB(TM.get(),
-(PGOOpt.RunProfileGen ||
+(PGOOpt.RunProfileGen || PGOOpt.SampleProfileGen ||
   !PGOOpt.ProfileUseFile.empty() ||
   !PGOOpt.SampleProfileFile.empty()) ?
 Optional(PGOOpt) : None);


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -855,10 +855,13 @@
   if (!CodeGenOpts.SampleProfileFile.empty())
 PGOOpt.SampleProfileFile = CodeGenOpts.SampleProfileFile;
 
+  if (CodeGenOpts.DebugInfoForProfiling)
+PGOOpt.SampleProfileGen = true;
+
   // Only pass a PGO options struct if -fprofile-generate or
   // -fprofile-use were passed on the cmdline.
   PassBuilder PB(TM.get(),
-(PGOOpt.RunProfileGen ||
+(PGOOpt.RunProfileGen || PGOOpt.SampleProfileGen ||
   !PGOOpt.ProfileUseFile.empty() ||
   !PGOOpt.SampleProfileFile.empty()) ?
 Optional(PGOOpt) : None);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35824: [Sema] Implicitly apply the may_alias attribute to std::byte

2017-07-25 Thread David Majnemer via Phabricator via cfe-commits
majnemer updated this revision to Diff 108166.
majnemer added a comment.

- Address review comments


https://reviews.llvm.org/D35824

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  test/CodeGenCXX/std-byte.cpp


Index: test/CodeGenCXX/std-byte.cpp
===
--- /dev/null
+++ test/CodeGenCXX/std-byte.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm 
-O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+// CHECK-LABEL: define void @test0(
+extern "C" void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}} !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+enum byte : unsigned char {};
+namespace my {
+enum byte : unsigned char {};
+namespace std {
+enum byte : unsigned char {};
+} // namespace std
+} // namespace my
+
+// Make sure we don't get confused with other enums named 'byte'.
+
+// CHECK-LABEL: define void @test1(
+extern "C" void test1(::byte *b, ::my::byte *mb, ::my::std::byte *msb) {
+  *b = ::byte{0};
+  *mb = ::my::byte{0};
+  *msb = ::my::std::byte{0};
+  // CHECK-NOT: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR]]
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -85,6 +85,12 @@
 return TypeHasMayAlias(TTy->desugar());
   }
 
+  // C++1z [intro.object]p3: If a complete object is created in storage
+  // associated with another object e of type [...] "array of N std::byte", 
that
+  // array provides storage for the created object [...].
+  if (QTy->isStdByteType())
+return true;
+
   return false;
 }
 
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2313,6 +2313,15 @@
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+  return true;
+  }
+  return false;
+}
+
 bool Type::isPromotableIntegerType() const {
   if (const BuiltinType *BT = getAs())
 switch (BT->getKind()) {
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1752,6 +1752,7 @@
   bool isTemplateTypeParmType() const;  // C++ template type parameter
   bool isNullPtrType() const;   // C++11 std::nullptr_t
   bool isAlignValT() const; // C++17 std::align_val_t
+  bool isStdByteType() const;   // C++17 std::byte
   bool isAtomicType() const;// C11 _Atomic()
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \


Index: test/CodeGenCXX/std-byte.cpp
===
--- /dev/null
+++ test/CodeGenCXX/std-byte.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+// CHECK-LABEL: define void @test0(
+extern "C" void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}} !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+enum byte : unsigned char {};
+namespace my {
+enum byte : unsigned char {};
+namespace std {
+enum byte : unsigned char {};
+} // namespace std
+} // namespace my
+
+// Make sure we don't get confused with other enums named 'byte'.
+
+// CHECK-LABEL: define void @test1(
+extern "C" void test1(::byte *b, ::my::byte *mb, ::my::std::byte *msb) {
+  *b = ::byte{0};
+  *mb = ::my::byte{0};
+  *msb = ::my::std::byte{0};
+  // CHECK-NOT: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR]]
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
Index: lib/CodeGen/CodeGenTBAA.cpp

r309036 - [StaticAnalyzer] LoopUnrolling - Attempt to fix a crash in r309006.

2017-07-25 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Tue Jul 25 14:54:58 2017
New Revision: 309036

URL: http://llvm.org/viewvc/llvm-project?rev=309036=rev
Log:
[StaticAnalyzer] LoopUnrolling - Attempt to fix a crash in r309006.


Modified:
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp?rev=309036=309035=309036=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp Tue Jul 25 14:54:58 2017
@@ -183,8 +183,10 @@ bool isUnrolledLoopBlock(const CFGBlock
 LBV.setBlocksOfLoop(E.first, M);
 // In case of an inlined function call check if any of its callSiteBlock is
 // marked.
-while (SearchedBlock && BlockSet.find(SearchedBlock) == BlockSet.end()) {
+while (BlockSet.find(SearchedBlock) == BlockSet.end() && 
!StackFrame->inTopFrame()) {
   SearchedBlock = StackFrame->getCallSiteBlock();
+  if(!SearchedBlock)
+break;
   StackFrame = StackFrame->getParent()->getCurrentStackFrame();
 }
 delete M;


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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D28691#820641, @b-sumner wrote:

> In https://reviews.llvm.org/D28691#820595, @rjmccall wrote:
>
> > In https://reviews.llvm.org/D28691#820541, @b-sumner wrote:
> >
> > > There are other languages for heterogeneous compute that have scopes, 
> > > although not exposed quite as explicitly as OpenCL.  For example AMD's 
> > > "HC" language.  And any language making use of clang and targeting SPIR-V 
> > > would likely use these builtins.  I think a more generic prefix is 
> > > appropriate, and "scoped" tells us exactly when these are needed.
> >
> >
> > But would those languages use the same language design for these scopes as 
> > OpenCL if they did expose them, as opposed to some more elaborate scoping 
> > specification?  My objection is not that the concept is inherently 
> > OpenCL-specific, it's that the presentation in the language might be 
> > inherently OpenCL-specific, which makes staying in the opencl namespace is 
> > prudent.
>
>
> Are you envisioning a language far enough from C/C++ that a standard library 
> or header would not be able to map a scoped atomic operation into a call to 
> one of these new builtins?  Would we expect more of such languages than 
> languages that would do such a mapping?


If you're using Clang as a frontend for your language, it must be similar 
enough to C to call a builtin function.  That's not at issue.  The central 
question here is whether these builtins are meaningfully general outside of 
OpenCL.  The concept of heterogenous computation is certainly not specific to 
OpenCL;  however, these builtins are defined in terms of scopes — "work item", 
"work group", "device", and "all svm devices" — which, it seems to me, are 
basically only defined by reference to the OpenCL architecture.  A different 
heterogenous compute environment might reasonably formalize scopes in a 
completely different way; for example, it might wish to be more explicit about 
exactly which peers / devices to synchronize with.

SPIR is explicitly defined on top of the OpenCL model.  Users should be able to 
use OpenCL builtins when targeting it.  That does not make those builtins more 
general than OpenCL.

John.


https://reviews.llvm.org/D28691



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In https://reviews.llvm.org/D28691#820595, @rjmccall wrote:

> In https://reviews.llvm.org/D28691#820541, @b-sumner wrote:
>
> > There are other languages for heterogeneous compute that have scopes, 
> > although not exposed quite as explicitly as OpenCL.  For example AMD's "HC" 
> > language.  And any language making use of clang and targeting SPIR-V would 
> > likely use these builtins.  I think a more generic prefix is appropriate, 
> > and "scoped" tells us exactly when these are needed.
>
>
> But would those languages use the same language design for these scopes as 
> OpenCL if they did expose them, as opposed to some more elaborate scoping 
> specification?  My objection is not that the concept is inherently 
> OpenCL-specific, it's that the presentation in the language might be 
> inherently OpenCL-specific, which makes staying in the opencl namespace is 
> prudent.


Are you envisioning a language far enough from C/C++ that a standard library or 
header would not be able to map a scoped atomic operation into a call to one of 
these new builtins?  Would we expect more of such languages than languages that 
would do such a mapping?


https://reviews.llvm.org/D28691



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


[PATCH] D35854: Fix double destruction of objects when OpenMP construct is canceled

2017-07-25 Thread Mike Rice via Phabricator via cfe-commits
mikerice created this revision.

When an omp for loop is canceled the constructed objects are being destructed 
twice.

It looks like the desired code is:

{

  Obj o;
  If (cancelled) branch-through-cleanups to cancel.exit.

}
[cleanups]
cancel.exit:

  __kmpc_for_static_fini
  br cancel.cont (*)

cancel.cont:

  __kmpc_barrier
  return

The problem seems to be the branch to cancel.cont is currently also going 
through the cleanups calling them again.  This change just does a direct branch 
instead.


https://reviews.llvm.org/D35854

Files:
  lib/CodeGen/CodeGenFunction.h
  test/OpenMP/cancel_codegen_cleanup.cpp


Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1116,7 +1116,7 @@
 auto IP = CGF.Builder.saveAndClearIP();
 CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
 CodeGen(CGF);
-CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
+CGF.EmitBranch(Stack.back().ContBlock.getBlock());
 CGF.Builder.restoreIP(IP);
 Stack.back().HasBeenEmitted = true;
   }
Index: test/OpenMP/cancel_codegen_cleanup.cpp
===
--- test/OpenMP/cancel_codegen_cleanup.cpp
+++ test/OpenMP/cancel_codegen_cleanup.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fopenmp -fopenmp-version=45 -triple 
x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s
+
+//CHECK: call i32 @__kmpc_cancel
+//CHECK: br {{.*}}label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
+//CHECK: [[EXIT]]:
+//CHECK: store i32 [[EXIT_SLOT:[0-9]+]]
+//CHECK: br label %[[CLEANUP:.+]]
+//CHECK: [[CONTINUE]]:
+//CHECK: store i32 [[CONT_SLOT:[0-9]+]],
+//CHECK: br label %[[CLEANUP]]
+//CHECK: [[CLEANUP]]:
+//CHECK-NEXT: call void @_ZN3ObjD1Ev
+//CHECK: switch i32{{.*}}, label %[[UNREACHABLE:.+]] [
+//CHECK:   i32 [[CONT_SLOT]], label %[[CLEANUPCONT:.+]]
+//CHECK:   i32 [[EXIT_SLOT]], label %[[CANCELEXIT:.+]]
+//CHECK-NEXT: ]
+//CHECK: [[CLEANUPCONT]]:
+//CHECK: br label %[[CANCELCONT:.+]]
+//CHECK: [[CANCELCONT]]:
+//CHECK-NEXT: call void @__kmpc_barrier(
+//CHECK-NEXT: ret void
+//CHECK: [[UNREACHABLE]]:
+//CHECK-NEXT: unreachable
+//CHECK-NEXT: }
+
+struct Obj {
+  int a; Obj(); Obj(const Obj& r) = delete; Obj =(const Obj& r);
+  ~Obj();
+};
+ 
+void foo() {
+  int i,count = 0;
+  Obj obj;
+
+  #pragma omp parallel private(i) num_threads(1)
+  {
+  #pragma omp for reduction(+:count) lastprivate(obj)
+  for (i=0; i<1000; i++) {
+if(i==100) {
+obj.a = 100;
+#pragma omp cancel for
+}
+count++;
+}
+}
+}


Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1116,7 +1116,7 @@
 auto IP = CGF.Builder.saveAndClearIP();
 CGF.EmitBlock(Stack.back().ExitBlock.getBlock());
 CodeGen(CGF);
-CGF.EmitBranchThroughCleanup(Stack.back().ContBlock);
+CGF.EmitBranch(Stack.back().ContBlock.getBlock());
 CGF.Builder.restoreIP(IP);
 Stack.back().HasBeenEmitted = true;
   }
Index: test/OpenMP/cancel_codegen_cleanup.cpp
===
--- test/OpenMP/cancel_codegen_cleanup.cpp
+++ test/OpenMP/cancel_codegen_cleanup.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fopenmp -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s
+
+//CHECK: call i32 @__kmpc_cancel
+//CHECK: br {{.*}}label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
+//CHECK: [[EXIT]]:
+//CHECK: store i32 [[EXIT_SLOT:[0-9]+]]
+//CHECK: br label %[[CLEANUP:.+]]
+//CHECK: [[CONTINUE]]:
+//CHECK: store i32 [[CONT_SLOT:[0-9]+]],
+//CHECK: br label %[[CLEANUP]]
+//CHECK: [[CLEANUP]]:
+//CHECK-NEXT: call void @_ZN3ObjD1Ev
+//CHECK: switch i32{{.*}}, label %[[UNREACHABLE:.+]] [
+//CHECK:   i32 [[CONT_SLOT]], label %[[CLEANUPCONT:.+]]
+//CHECK:   i32 [[EXIT_SLOT]], label %[[CANCELEXIT:.+]]
+//CHECK-NEXT: ]
+//CHECK: [[CLEANUPCONT]]:
+//CHECK: br label %[[CANCELCONT:.+]]
+//CHECK: [[CANCELCONT]]:
+//CHECK-NEXT: call void @__kmpc_barrier(
+//CHECK-NEXT: ret void
+//CHECK: [[UNREACHABLE]]:
+//CHECK-NEXT: unreachable
+//CHECK-NEXT: }
+
+struct Obj {
+  int a; Obj(); Obj(const Obj& r) = delete; Obj =(const Obj& r);
+  ~Obj();
+};
+ 
+void foo() {
+  int i,count = 0;
+  Obj obj;
+
+  #pragma omp parallel private(i) num_threads(1)
+  {
+  #pragma omp for reduction(+:count) lastprivate(obj)
+  for (i=0; i<1000; i++) {
+if(i==100) {
+obj.a = 100;
+#pragma omp cancel for
+}
+count++;
+}
+}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35849: [UBSan] Provide default blacklist filename for UBSan

2017-07-25 Thread Han Shen via Phabricator via cfe-commits
shenhan added a comment.

Thanks for pointing out the relevant CLs. I agree that's the clearer and better 
solution.

(The only concern is that it has been sitting there for 2 months. I'll check 
back.)

In https://reviews.llvm.org/D35849#820473, @vsk wrote:

> This won't do the right thing if more than one sanitizer with a default 
> blacklist is enabled. It's also problematic that a default blacklist for one 
> sanitizer can blacklist code for a different sanitizer. See:
>
> https://reviews.llvm.org/D32043
>  https://reviews.llvm.org/D32047
>  https://reviews.llvm.org/D32842
>
> IMO I think https://reviews.llvm.org/D32842 is the right path forward. I 
> don't have the time to get back to it this week, but if you'd like to pick it 
> up and respond to review feedback from @eugenis, please do (I can certainly 
> help with the review).





https://reviews.llvm.org/D35849



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


[PATCH] D32842: Specify which sanitizers are covered by a sanitizer blacklist

2017-07-25 Thread Han Shen via Phabricator via cfe-commits
shenhan added a comment.

Thanks. Can you update "SanitizerArgs::collectDefaultBlacklists" to include 
"ubsan_blacklist.txt"?


https://reviews.llvm.org/D32842



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D28691#820541, @b-sumner wrote:

> There are other languages for heterogeneous compute that have scopes, 
> although not exposed quite as explicitly as OpenCL.  For example AMD's "HC" 
> language.  And any language making use of clang and targeting SPIR-V would 
> likely use these builtins.  I think a more generic prefix is appropriate, and 
> "scoped" tells us exactly when these are needed.


But would those languages use the same language design for these scopes as 
OpenCL if they did expose them, as opposed to some more elaborate scoping 
specification?  My objection is not that the concept is inherently 
OpenCL-specific, it's that the presentation in the language might be inherently 
OpenCL-specific, which makes staying in the opencl namespace is prudent.


https://reviews.llvm.org/D28691



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


r309018 - Fix a bot by linking clang-import-test against libclangDriver

2017-07-25 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Tue Jul 25 13:09:30 2017
New Revision: 309018

URL: http://llvm.org/viewvc/llvm-project?rev=309018=rev
Log:
Fix a bot by linking clang-import-test against libclangDriver

Modified:
cfe/trunk/tools/clang-import-test/CMakeLists.txt

Modified: cfe/trunk/tools/clang-import-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/CMakeLists.txt?rev=309018=309017=309018=diff
==
--- cfe/trunk/tools/clang-import-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-import-test/CMakeLists.txt Tue Jul 25 13:09:30 2017
@@ -17,6 +17,7 @@ set(CLANG_IMPORT_TEST_LIB_DEPS
   clangAST
   clangBasic
   clangCodeGen
+  clangDriver
   clangFrontend
   clangLex
   clangParse


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


[PATCH] D35673: [analyzer] A better CFG-based suppress-on-sink.

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp:3313
 
+static bool isDominatedByNoReturnBlocks(const ExplodedNode *N) {
+  const CFG  = N->getCFG();

Do you really mean "is dominated by"? That is, "every path from the entry to 
N's block goes through a no-return block"? Or do you mean "the exit block is 
not reachable from N's block"?


Repository:
  rL LLVM

https://reviews.llvm.org/D35673



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


[PATCH] D35729: [Frontend] - Mark some ASTUnit methods as const

2017-07-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309013: [Frontend] Mark some ASTUnit methods as const. NFC. 
(authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D35729?vs=107689=108138#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35729

Files:
  cfe/trunk/include/clang/Frontend/ASTUnit.h
  cfe/trunk/lib/Frontend/ASTUnit.cpp

Index: cfe/trunk/include/clang/Frontend/ASTUnit.h
===
--- cfe/trunk/include/clang/Frontend/ASTUnit.h
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h
@@ -448,7 +448,7 @@
 
   IntrusiveRefCntPtr getASTReader() const;
 
-  StringRef getOriginalSourceFileName() {
+  StringRef getOriginalSourceFileName() const {
 return OriginalSourceFile;
   }
 
@@ -524,26 +524,26 @@
   /// \brief If \p Loc is a loaded location from the preamble, returns
   /// the corresponding local location of the main file, otherwise it returns
   /// \p Loc.
-  SourceLocation mapLocationFromPreamble(SourceLocation Loc);
+  SourceLocation mapLocationFromPreamble(SourceLocation Loc) const;
 
   /// \brief If \p Loc is a local location of the main file but inside the
   /// preamble chunk, returns the corresponding loaded location from the
   /// preamble, otherwise it returns \p Loc.
-  SourceLocation mapLocationToPreamble(SourceLocation Loc);
+  SourceLocation mapLocationToPreamble(SourceLocation Loc) const;
 
-  bool isInPreambleFileID(SourceLocation Loc);
-  bool isInMainFileID(SourceLocation Loc);
-  SourceLocation getStartOfMainFileID();
-  SourceLocation getEndOfPreambleFileID();
+  bool isInPreambleFileID(SourceLocation Loc) const;
+  bool isInMainFileID(SourceLocation Loc) const;
+  SourceLocation getStartOfMainFileID() const;
+  SourceLocation getEndOfPreambleFileID() const;
 
   /// \see mapLocationFromPreamble.
-  SourceRange mapRangeFromPreamble(SourceRange R) {
+  SourceRange mapRangeFromPreamble(SourceRange R) const {
 return SourceRange(mapLocationFromPreamble(R.getBegin()),
mapLocationFromPreamble(R.getEnd()));
   }
 
   /// \see mapLocationToPreamble.
-  SourceRange mapRangeToPreamble(SourceRange R) {
+  SourceRange mapRangeToPreamble(SourceRange R) const {
 return SourceRange(mapLocationToPreamble(R.getBegin()),
mapLocationToPreamble(R.getEnd()));
   }
@@ -607,7 +607,7 @@
 
   /// \brief Returns true if the ASTUnit was constructed from a serialized
   /// module file.
-  bool isModuleFile();
+  bool isModuleFile() const;
 
   std::unique_ptr
   getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);
Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -2395,7 +2395,7 @@
 /// \brief If \arg Loc is a loaded location from the preamble, returns
 /// the corresponding local location of the main file, otherwise it returns
 /// \arg Loc.
-SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2416,7 +2416,7 @@
 /// \brief If \arg Loc is a local location of the main file but inside the
 /// preamble chunk, returns the corresponding loaded location from the
 /// preamble, otherwise it returns \arg Loc.
-SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2434,7 +2434,7 @@
   return Loc;
 }
 
-bool ASTUnit::isInPreambleFileID(SourceLocation Loc) {
+bool ASTUnit::isInPreambleFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID();
@@ -2445,7 +2445,7 @@
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-bool ASTUnit::isInMainFileID(SourceLocation Loc) {
+bool ASTUnit::isInMainFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getMainFileID();
@@ -2456,7 +2456,7 @@
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-SourceLocation ASTUnit::getEndOfPreambleFileID() {
+SourceLocation ASTUnit::getEndOfPreambleFileID() const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID();
@@ -2467,7 +2467,7 @@
   return SourceMgr->getLocForEndOfFile(FID);
 }
 
-SourceLocation ASTUnit::getStartOfMainFileID() {
+SourceLocation ASTUnit::getStartOfMainFileID() const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getMainFileID();
@@ -2543,7 +2543,7 @@
   return nullptr;
 }
 
-bool ASTUnit::isModuleFile() {
+bool ASTUnit::isModuleFile() const {
   return isMainFileAST() && getLangOpts().isCompilingModule();
 }
 
___
cfe-commits mailing list

r309014 - [ExternalASTMerger] Import Objective-C classes

2017-07-25 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Tue Jul 25 12:54:22 2017
New Revision: 309014

URL: http://llvm.org/viewvc/llvm-project?rev=309014=rev
Log:
[ExternalASTMerger] Import Objective-C classes

This patch adds functionality and a test for importing Objective-C classes
and their methods.

It also adds a flag to clang-import-test to set the language used for
parsing. This takes the same argument format as the -x option to the
driver.

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

Added:
cfe/trunk/test/Import/objc-method/
  - copied from r308993, cfe/trunk/test/Import/member-in-struct/
cfe/trunk/test/Import/objc-method/Inputs/S.m
  - copied, changed from r308993, 
cfe/trunk/test/Import/member-in-struct/Inputs/S.c
cfe/trunk/test/Import/objc-method/test.m
  - copied, changed from r308993, 
cfe/trunk/test/Import/member-in-struct/test.c
Removed:
cfe/trunk/test/Import/objc-method/Inputs/S.c
cfe/trunk/test/Import/objc-method/test.c
Modified:
cfe/trunk/lib/AST/ExternalASTMerger.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=309014=309013=309014=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Tue Jul 25 12:54:22 2017
@@ -44,6 +44,9 @@ public:
   ToTag->setMustBuildLookupTable();
 } else if (auto ToNamespace = dyn_cast(To)) {
   ToNamespace->setHasExternalVisibleStorage();
+} else if (auto ToContainer = dyn_cast(To)) {
+  ToContainer->setHasExternalLexicalStorage();
+  ToContainer->setMustBuildLookupTable();
 }
 return ASTImporter::Imported(From, To);
   }
@@ -80,11 +83,12 @@ LookupSameContext(Source(D)); // TODO handle this case
   if (auto TD = dyn_cast(D)) {
 return !TD->isThisDeclarationADefinition();
   } else if (auto FD = dyn_cast(D)) {
 return !FD->isThisDeclarationADefinition();
+  } else if (auto OID = dyn_cast(D)) {
+ return OID->isThisDeclarationADefinition();
   } else {
 return false;
   }

Removed: cfe/trunk/test/Import/objc-method/Inputs/S.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/member-in-struct/Inputs/S.c?rev=308993=auto
==
--- cfe/trunk/test/Import/objc-method/Inputs/S.c (original)
+++ cfe/trunk/test/Import/objc-method/Inputs/S.c (removed)
@@ -1,3 +0,0 @@
-struct S {
-  int a;
-};

Copied: cfe/trunk/test/Import/objc-method/Inputs/S.m (from r308993, 
cfe/trunk/test/Import/member-in-struct/Inputs/S.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-method/Inputs/S.m?p2=cfe/trunk/test/Import/objc-method/Inputs/S.m=cfe/trunk/test/Import/member-in-struct/Inputs/S.c=308993=309014=309014=diff
==
--- cfe/trunk/test/Import/member-in-struct/Inputs/S.c (original)
+++ cfe/trunk/test/Import/objc-method/Inputs/S.m Tue Jul 25 12:54:22 2017
@@ -1,3 +1,4 @@
-struct S {
-  int a;
-};
+@interface C {
+}
+-(int)m;
+@end

Removed: cfe/trunk/test/Import/objc-method/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/member-in-struct/test.c?rev=308993=auto
==
--- cfe/trunk/test/Import/objc-method/test.c (original)
+++ cfe/trunk/test/Import/objc-method/test.c (removed)
@@ -1,5 +0,0 @@
-// RUN: clang-import-test -import %S/Inputs/S.c -expression %s
-void expr() {
-  struct S MyS;
-  MyS.a = 3;
-}

Copied: cfe/trunk/test/Import/objc-method/test.m (from r308993, 
cfe/trunk/test/Import/member-in-struct/test.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/objc-method/test.m?p2=cfe/trunk/test/Import/objc-method/test.m=cfe/trunk/test/Import/member-in-struct/test.c=308993=309014=309014=diff
==
--- cfe/trunk/test/Import/member-in-struct/test.c (original)
+++ cfe/trunk/test/Import/objc-method/test.m Tue Jul 25 12:54:22 2017
@@ -1,5 +1,5 @@
-// RUN: clang-import-test -import %S/Inputs/S.c -expression %s
+// RUN: clang-import-test -x objective-c++ -import %S/Inputs/S.m -expression %s
 void expr() {
-  struct S MyS;
-  MyS.a = 3;
+  C *c;
+  int i = [c m];
 }

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=309014=309013=309014=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Jul 25 12:54:22 
2017
@@ -17,6 +17,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include 

r309013 - [Frontend] Mark some ASTUnit methods as const. NFC.

2017-07-25 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Jul 25 12:53:27 2017
New Revision: 309013

URL: http://llvm.org/viewvc/llvm-project?rev=309013=rev
Log:
[Frontend] Mark some ASTUnit methods as const. NFC.

Patch by Hamza Sood!

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

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=309013=309012=309013=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue Jul 25 12:53:27 2017
@@ -448,7 +448,7 @@ public:
 
   IntrusiveRefCntPtr getASTReader() const;
 
-  StringRef getOriginalSourceFileName() {
+  StringRef getOriginalSourceFileName() const {
 return OriginalSourceFile;
   }
 
@@ -524,26 +524,26 @@ public:
   /// \brief If \p Loc is a loaded location from the preamble, returns
   /// the corresponding local location of the main file, otherwise it returns
   /// \p Loc.
-  SourceLocation mapLocationFromPreamble(SourceLocation Loc);
+  SourceLocation mapLocationFromPreamble(SourceLocation Loc) const;
 
   /// \brief If \p Loc is a local location of the main file but inside the
   /// preamble chunk, returns the corresponding loaded location from the
   /// preamble, otherwise it returns \p Loc.
-  SourceLocation mapLocationToPreamble(SourceLocation Loc);
+  SourceLocation mapLocationToPreamble(SourceLocation Loc) const;
 
-  bool isInPreambleFileID(SourceLocation Loc);
-  bool isInMainFileID(SourceLocation Loc);
-  SourceLocation getStartOfMainFileID();
-  SourceLocation getEndOfPreambleFileID();
+  bool isInPreambleFileID(SourceLocation Loc) const;
+  bool isInMainFileID(SourceLocation Loc) const;
+  SourceLocation getStartOfMainFileID() const;
+  SourceLocation getEndOfPreambleFileID() const;
 
   /// \see mapLocationFromPreamble.
-  SourceRange mapRangeFromPreamble(SourceRange R) {
+  SourceRange mapRangeFromPreamble(SourceRange R) const {
 return SourceRange(mapLocationFromPreamble(R.getBegin()),
mapLocationFromPreamble(R.getEnd()));
   }
 
   /// \see mapLocationToPreamble.
-  SourceRange mapRangeToPreamble(SourceRange R) {
+  SourceRange mapRangeToPreamble(SourceRange R) const {
 return SourceRange(mapLocationToPreamble(R.getBegin()),
mapLocationToPreamble(R.getEnd()));
   }
@@ -607,7 +607,7 @@ public:
 
   /// \brief Returns true if the ASTUnit was constructed from a serialized
   /// module file.
-  bool isModuleFile();
+  bool isModuleFile() const;
 
   std::unique_ptr
   getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=309013=309012=309013=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Jul 25 12:53:27 2017
@@ -2395,7 +2395,7 @@ SourceLocation ASTUnit::getLocation(cons
 /// \brief If \arg Loc is a loaded location from the preamble, returns
 /// the corresponding local location of the main file, otherwise it returns
 /// \arg Loc.
-SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationFromPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2416,7 +2416,7 @@ SourceLocation ASTUnit::mapLocationFromP
 /// \brief If \arg Loc is a local location of the main file but inside the
 /// preamble chunk, returns the corresponding loaded location from the
 /// preamble, otherwise it returns \arg Loc.
-SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) {
+SourceLocation ASTUnit::mapLocationToPreamble(SourceLocation Loc) const {
   FileID PreambleID;
   if (SourceMgr)
 PreambleID = SourceMgr->getPreambleFileID();
@@ -2434,7 +2434,7 @@ SourceLocation ASTUnit::mapLocationToPre
   return Loc;
 }
 
-bool ASTUnit::isInPreambleFileID(SourceLocation Loc) {
+bool ASTUnit::isInPreambleFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID();
@@ -2445,7 +2445,7 @@ bool ASTUnit::isInPreambleFileID(SourceL
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-bool ASTUnit::isInMainFileID(SourceLocation Loc) {
+bool ASTUnit::isInMainFileID(SourceLocation Loc) const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getMainFileID();
@@ -2456,7 +2456,7 @@ bool ASTUnit::isInMainFileID(SourceLocat
   return SourceMgr->isInFileID(Loc, FID);
 }
 
-SourceLocation ASTUnit::getEndOfPreambleFileID() {
+SourceLocation ASTUnit::getEndOfPreambleFileID() const {
   FileID FID;
   if (SourceMgr)
 FID = SourceMgr->getPreambleFileID();
@@ -2467,7 +2467,7 @@ 

Re: [PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Joerg Sonnenberger via cfe-commits
On Tue, Jul 25, 2017 at 03:09:00PM -0400, Nico Weber via cfe-commits wrote:
> On Tue, Jul 25, 2017 at 2:53 PM, Joerg Sonnenberger  wrote:
> 
> > On Sun, Jul 23, 2017 at 07:06:25PM -0400, Nico Weber via cfe-commits wrote:
> > > If you need this behavior for something, that sounds like something a
> > > -nodefaultlibs++ could do. -nostdlib++ is really meant to disable the c++
> > > stdlib and nothing else.
> >
> > But the -lm is only there because -lc++ alone (or -lstdc++ for that
> > matter) wouldn't really work.
> >
> 
> Do you have a reference for that? Several toolchains link in -lm in C mode
> even.

UNIX history?

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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In https://reviews.llvm.org/D28691#820526, @rjmccall wrote:

> In https://reviews.llvm.org/D28691#820489, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D28691#820466, @b-sumner wrote:
> >
> > > Can we drop the "opencl" part of the name and use something like 
> > > __scoped_atomic_*?   Also, it may not make sense to support non-constant 
> > > scope here since we can't predict what other scopes may be added by other 
> > > languages in the future.
> >
> >
> > we could use the approach of LangAS, i.e. we allow targets to map all 
> > language specific scopes to target-specific scope names, since IR only 
> > cares about scope names, which are target specific. And this is what the 
> > current implementation does.
> >
> > I have no objection to use the __scoped_atomic_ name. It is more general 
> > and extensible. John/Anastasia, any comments? Thanks.
>
>
> I think I would prefer __opencl_atomic_* until we have some evidence that 
> this concept is more general than just OpenCL.


There are other languages for heterogeneous compute that have scopes, although 
not exposed quite as explicitly as OpenCL.  For example AMD's "HC" language.  
And any language making use of clang and targeting SPIR-V would likely use 
these builtins.  I think a more generic prefix is appropriate, and "scoped" 
tells us exactly when these are needed.


https://reviews.llvm.org/D28691



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


[PATCH] D35736: [ubsan] -fsanitize=vptr now requires -fsanitize=null, update tests

2017-07-25 Thread Vedant Kumar via Phabricator via cfe-commits
vsk closed this revision.
vsk added a comment.

Thanks! This landed in r309008.


https://reviews.llvm.org/D35736



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


[PATCH] D35735: [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-25 Thread Vedant Kumar via Phabricator via cfe-commits
vsk marked an inline comment as done.
vsk added a comment.

I made the suggested test changes and updated the release notes: r309007


Repository:
  rL LLVM

https://reviews.llvm.org/D35735



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


[PATCH] D35735: [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309007: [ubsan] Null-check pointers in -fsanitize=vptr 
(PR33881) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D35735?vs=107741=108133#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35735

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
  cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
  cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
  cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
  cfe/trunk/test/Driver/fsanitize.c
  cfe/trunk/test/Driver/rtti-options.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -27,6 +27,7 @@
 def GNUAutoType : DiagGroup<"gnu-auto-type">;
 def ArrayBounds : DiagGroup<"array-bounds">;
 def ArrayBoundsPointerArithmetic : DiagGroup<"array-bounds-pointer-arithmetic">;
+def AutoDisableVptrSanitizer : DiagGroup<"auto-disable-vptr-sanitizer">;
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -230,7 +230,10 @@
   InGroup>;
 def warn_drv_disabling_vptr_no_rtti_default : Warning<
   "implicitly disabling vptr sanitizer because rtti wasn't enabled">,
-  InGroup>;
+  InGroup;
+def warn_drv_disabling_vptr_no_null_check : Warning<
+  "implicitly disabling vptr sanitizer because null checking wasn't enabled">,
+  InGroup;
 def warn_drv_object_size_disabled_O0 : Warning<
   "the object size sanitizer has no effect at -O0, but is explicitly enabled: %0">,
   InGroup;
Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -58,6 +58,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-NO-RTTI
 // CHECK-UNDEFINED-NO-RTTI-NOT: vptr
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-sanitize=null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-NULL
+// CHECK-VPTR-NO-NULL: warning: implicitly disabling vptr sanitizer because null checking wasn't enabled
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
 // CHECK-SANA-SANT: '-fsanitize=address' not allowed with '-fsanitize=thread'
 
@@ -362,8 +366,8 @@
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.8 -fsanitize=vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-OLD
 // CHECK-VPTR-DARWIN-OLD: unsupported option '-fsanitize=vptr' for target 'x86_64-apple-darwin10'
 
-// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.9 -fsanitize=alignment,vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-NEW
-// CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,vptr
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.9 -fsanitize=alignment,null,vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-DARWIN-NEW
+// CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,null,vptr
 
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
 // CHECK-ASAN-IOS: -fsanitize=address
Index: cfe/trunk/test/Driver/rtti-options.cpp
===
--- cfe/trunk/test/Driver/rtti-options.cpp
+++ cfe/trunk/test/Driver/rtti-options.cpp
@@ -16,14 +16,14 @@
 // Make sure we only error/warn once, when trying to enable vptr and
 // undefined and have -fno-rtti
 // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s
-// RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=vptr 

r309007 - [ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

2017-07-25 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Jul 25 12:34:23 2017
New Revision: 309007

URL: http://llvm.org/viewvc/llvm-project?rev=309007=rev
Log:
[ubsan] Null-check pointers in -fsanitize=vptr (PR33881)

The instrumentation generated by -fsanitize=vptr does not null check a
user pointer before loading from it. This causes crashes in the face of
UB member calls (this=nullptr), i.e it's causing user programs to crash
only after UBSan is turned on.

The fix is to make run-time null checking a prerequisite for enabling
-fsanitize=vptr, and to then teach UBSan to reuse these run-time null
checks to make -fsanitize=vptr safe.

Testing: check-clang, check-ubsan, a stage2 ubsan-enabled build

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

https://bugs.llvm.org/show_bug.cgi?id=33881

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
cfe/trunk/test/CodeGenCXX/ubsan-vtable-checks.cpp
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/rtti-options.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=309007=309006=309007=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul 25 12:34:23 2017
@@ -155,7 +155,9 @@ Static Analyzer
 Undefined Behavior Sanitizer (UBSan)
 
 
-...
+The C++ dynamic type check now requires run-time null checking (i.e,
+`-fsanitize=vptr` cannot be used without `-fsanitize=null`). This change does
+not impact users who rely on UBSan check groups (e.g `-fsanitize=undefined`).
 
 Core Analysis Improvements
 ==

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=309007=309006=309007=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Tue Jul 25 12:34:23 2017
@@ -130,11 +130,11 @@ Available checks are:
  it is often unintentional, so UBSan offers to catch it.
   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
  does not evaluate to a positive value.
-  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that
- it is of the wrong dynamic type, or that its lifetime has not
- begun or has ended. Incompatible with ``-fno-rtti``. Link must
- be performed by ``clang++``, not ``clang``, to make sure C++-specific
- parts of the runtime library and C++ standard libraries are present.
+  -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that it is of
+ the wrong dynamic type, or that its lifetime has not begun or has ended.
+ Incompatible with ``-fno-rtti`` and ``-fno-sanitize=null``. Link must be
+ performed by ``clang++``, not ``clang``, to make sure C++-specific parts 
of
+ the runtime library and C++ standard libraries are present.
 
 You can also use the following check groups:
   -  ``-fsanitize=undefined``: All of the checks listed above other than

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=309007=309006=309007=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jul 25 12:34:23 
2017
@@ -230,7 +230,10 @@ def warn_drv_enabling_rtti_with_exceptio
   InGroup>;
 def warn_drv_disabling_vptr_no_rtti_default : Warning<
   "implicitly disabling vptr sanitizer because rtti wasn't enabled">,
-  InGroup>;
+  InGroup;
+def warn_drv_disabling_vptr_no_null_check : Warning<
+  "implicitly disabling vptr sanitizer because null checking wasn't enabled">,
+  InGroup;
 def warn_drv_object_size_disabled_O0 : Warning<
   "the object size sanitizer has no effect at -O0, but is explicitly enabled: 
%0">,
   InGroup;

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=309007=309006=309007=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jul 25 

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D28691#820489, @yaxunl wrote:

> In https://reviews.llvm.org/D28691#820466, @b-sumner wrote:
>
> > Can we drop the "opencl" part of the name and use something like 
> > __scoped_atomic_*?   Also, it may not make sense to support non-constant 
> > scope here since we can't predict what other scopes may be added by other 
> > languages in the future.
>
>
> we could use the approach of LangAS, i.e. we allow targets to map all 
> language specific scopes to target-specific scope names, since IR only cares 
> about scope names, which are target specific. And this is what the current 
> implementation does.
>
> I have no objection to use the __scoped_atomic_ name. It is more general and 
> extensible. John/Anastasia, any comments? Thanks.


I think I would prefer __opencl_atomic_* until we have some evidence that this 
concept is more general than just OpenCL.


https://reviews.llvm.org/D28691



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


r309006 - [StaticAnalyzer] Completely unrolling specific loops with known bound option

2017-07-25 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Tue Jul 25 12:23:23 2017
New Revision: 309006

URL: http://llvm.org/viewvc/llvm-project?rev=309006=rev
Log:
[StaticAnalyzer] Completely unrolling specific loops with known bound option

This feature allows the analyzer to consider loops to completely unroll.
New requirements/rules (for unrolling) can be added easily via ASTMatchers.

Right now it is hidden behind a flag, the aim is to find the correct heuristic
and create a solution which results higher coverage % and more precise
analysis, thus can be enabled by default.

Right now the blocks which belong to an unrolled loop are marked by the
LoopVisitor which adds them to the ProgramState.
Then whenever we encounter a CFGBlock in the processCFGBlockEntrance which is
marked then we skip its investigating. That means, it won't be considered to
be visited more than the maximal bound for visiting since it won't be checked.

Added:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
cfe/trunk/test/Analysis/loop-unrolling.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=309006=309005=309006=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Tue Jul 25 
12:23:23 2017
@@ -275,6 +275,9 @@ private:
   /// \sa shouldWidenLoops
   Optional WidenLoops;
 
+  /// \sa shouldUnrollLoops
+  Optional UnrollLoops;
+
   /// \sa shouldDisplayNotesAsEvents
   Optional DisplayNotesAsEvents;
 
@@ -560,6 +563,10 @@ public:
   /// This is controlled by the 'widen-loops' config option.
   bool shouldWidenLoops();
 
+  /// Returns true if the analysis should try to unroll loops with known 
bounds.
+  /// This is controlled by the 'unroll-loops' config option.
+  bool shouldUnrollLoops();
+
   /// Returns true if the bug reporter should transparently treat extra note
   /// diagnostic pieces as event diagnostic pieces. Useful when the diagnostic
   /// consumer doesn't support the extra note pieces.

Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h?rev=309006=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
(added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h 
Tue Jul 25 12:23:23 2017
@@ -0,0 +1,34 @@
+//===--- LoopUnrolling.h - Unroll loops -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// This header contains the declarations of functions which are used to decide
+/// which loops should be completely unrolled and mark their corresponding
+/// CFGBlocks.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_LOOPUNROLLING_H
+
+#include "clang/Analysis/CFG.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
+
+namespace clang {
+namespace ento {
+ProgramStateRef markLoopAsUnrolled(const Stmt *Term, ProgramStateRef State,
+   const FunctionDecl *FD);
+bool isUnrolledLoopBlock(const CFGBlock *Block, ExplodedNode *Pred,
+ AnalysisManager );
+bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext );
+
+} // end namespace ento
+} // end namespace clang
+
+#endif

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=309006=309005=309006=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp Tue Jul 25 
12:23:23 2017
@@ -272,6 

Re: [PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Eric Christopher via cfe-commits
And this:

echristo@athyra ~/s/llvm> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/llvm/trunk ...
M include/llvm/MC/MCParser/MCAsmParser.h
M lib/Target/X86/AsmParser/X86AsmParser.cpp
Committed r309005



On Tue, Jul 25, 2017 at 12:18 PM Eric Christopher 
wrote:

> I've reverted this and Nemanja's attempt at fixing in:
>
> echristo@athyra ~/s/l/t/clang> git svn dcommit
> Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
> D test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
> M lib/Sema/SemaStmtAsm.cpp
> M test/CodeGen/ms-inline-asm.c
> M test/CodeGenCXX/ms-inline-asm-return.cpp
> Committed r309004
>
> -eric
>
> On Tue, Jul 25, 2017 at 11:07 AM Nico Weber  wrote:
>
>> The test also fails on many other bots on
>> http://lab.llvm.org:8011/console , a short excerpt:
>>
>>
>> http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/9702/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/5197/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>>
>> On Tue, Jul 25, 2017 at 1:52 PM, Kostya Serebryany via Phabricator via
>> cfe-commits  wrote:
>>
>>> kcc added a comment.
>>>
>>> Hi.
>>> This patch causes the msan bots to complain. Please fix or revert ASAP.
>>>
>>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
>>> Testing: 0 .. 10..
>>> FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)
>>>
>>> - TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 
>>>
>>> Script:
>>> ---
>>>
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/clang
>>> -cc1 -internal-isystem
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/6.0.0/include
>>> -nostdsysteminc -triple x86_64-pc-win32 -fasm-blocks -emit-llvm
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>>> -o - |
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>>>
>>> --
>>>
>>> Exit Code: 2
>>>
>>> Command Output (stderr):
>>> 
>>>
>>> 4713==WARNING: MemorySanitizer: use-of-uninitialized-value
>>> --
>>>
>>>   #0 0x3143ba3 in (anonymous
>>> namespace)::X86AsmParser::ParseIntelIdentifier(llvm::MCExpr const*&,
>>> llvm::StringRef&, llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&)
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
>>>   #1 0x313f288 in (anonymous
>>> namespace)::X86AsmParser::ParseIntelExpression((anonymous
>>> namespace)::X86AsmParser::IntelExprStateMachine&, llvm::SMLoc&)
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
>>>   #2 0x31389e7 in (anonymous
>>> namespace)::X86AsmParser::ParseIntelBracExpression(unsigned int,
>>> llvm::SMLoc, long, bool, unsigned int)
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
>>>   #3 0x31307f8 in ParseIntelOperand
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1961:12
>>>   #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand()
>>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
>>>   #5 0x3118cda in (anonymous
>>> namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
>>> llvm::StringRef, llvm::SMLoc,
>>> llvm::SmallVectorImpl>> std::__1::default_delete > >&)
>>> 

Re: [PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Eric Christopher via cfe-commits
I've reverted this and Nemanja's attempt at fixing in:

echristo@athyra ~/s/l/t/clang> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
D test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
M lib/Sema/SemaStmtAsm.cpp
M test/CodeGen/ms-inline-asm.c
M test/CodeGenCXX/ms-inline-asm-return.cpp
Committed r309004

-eric

On Tue, Jul 25, 2017 at 11:07 AM Nico Weber  wrote:

> The test also fails on many other bots on http://lab.llvm.org:8011/console
> , a short excerpt:
>
>
> http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/9702/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/5197/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
>
> On Tue, Jul 25, 2017 at 1:52 PM, Kostya Serebryany via Phabricator via
> cfe-commits  wrote:
>
>> kcc added a comment.
>>
>> Hi.
>> This patch causes the msan bots to complain. Please fix or revert ASAP.
>>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
>> Testing: 0 .. 10..
>> FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)
>>
>> - TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 
>>
>> Script:
>> ---
>>
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/clang
>> -cc1 -internal-isystem
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/6.0.0/include
>> -nostdsysteminc -triple x86_64-pc-win32 -fasm-blocks -emit-llvm
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>> -o - |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
>>
>> --
>>
>> Exit Code: 2
>>
>> Command Output (stderr):
>> 
>>
>> 4713==WARNING: MemorySanitizer: use-of-uninitialized-value
>> --
>>
>>   #0 0x3143ba3 in (anonymous
>> namespace)::X86AsmParser::ParseIntelIdentifier(llvm::MCExpr const*&,
>> llvm::StringRef&, llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
>>   #1 0x313f288 in (anonymous
>> namespace)::X86AsmParser::ParseIntelExpression((anonymous
>> namespace)::X86AsmParser::IntelExprStateMachine&, llvm::SMLoc&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
>>   #2 0x31389e7 in (anonymous
>> namespace)::X86AsmParser::ParseIntelBracExpression(unsigned int,
>> llvm::SMLoc, long, bool, unsigned int)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
>>   #3 0x31307f8 in ParseIntelOperand
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1961:12
>>   #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand()
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
>>   #5 0x3118cda in (anonymous
>> namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&,
>> llvm::StringRef, llvm::SMLoc,
>> llvm::SmallVectorImpl> std::__1::default_delete > >&)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2510:44
>>   #6 0x4bb9a48 in (anonymous
>> namespace)::AsmParser::parseStatement((anonymous
>> namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*)
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/MC/MCParser/AsmParser.cpp:2034:42
>>   #7 0x4ba63a3 in (anonymous
>> namespace)::AsmParser::parseMSInlineAsm(void*, std::__1::basic_string> 

r309004 - Revert "This patch enables the usage of constant Enum identifiers within Microsoft style inline assembly statements." as it is causing msan failures.

2017-07-25 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Jul 25 12:17:32 2017
New Revision: 309004

URL: http://llvm.org/viewvc/llvm-project?rev=309004=rev
Log:
Revert "This patch enables the usage of constant Enum identifiers within 
Microsoft style inline assembly statements." as it is causing msan failures.

This reverts commits r308985 and r308965

Removed:
cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/CodeGen/ms-inline-asm.c
cfe/trunk/test/CodeGenCXX/ms-inline-asm-return.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=309004=309003=309004=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Jul 25 12:17:32 2017
@@ -645,8 +645,8 @@ ExprResult Sema::LookupInlineAsmIdentifi
   // Referring to parameters is not allowed in naked functions.
   if (CheckNakedParmReference(Result.get(), *this))
 return ExprError();
-  Expr *Res = Result.get();
-  QualType T = Res->getType();
+
+  QualType T = Result.get()->getType();
 
   if (T->isDependentType()) {
 return Result;
@@ -658,26 +658,16 @@ ExprResult Sema::LookupInlineAsmIdentifi
   }
 
   // Otherwise, it needs to be a complete type.
-  if (RequireCompleteExprType(Res, diag::err_asm_incomplete_type)) {
+  if (RequireCompleteExprType(Result.get(), diag::err_asm_incomplete_type)) {
 return ExprError();
   }
 
   fillInlineAsmTypeInfo(Context, T, Info);
 
   // We can work with the expression as long as it's not an r-value.
-  if (!Res->isRValue()) {
-Info.setKindVariable();
-return Result;
-  }
+  if (!Result.get()->isRValue())
+Info.IsVarDecl = true;
 
-  Expr::EvalResult EvlResult;
-  // Try to evaluate the identifier as enum constant, currently we do not allow
-  // other constant integers to be folded.
-  if (isa(T) &&
-Res->EvaluateAsRValue(EvlResult, getASTContext())) {
-Info.ConstIntValue = EvlResult.Val.getInt();
-Info.setKindConstEnum();
-  }
   return Result;
 }
 
@@ -784,7 +774,7 @@ Sema::LookupInlineAsmVarDeclField(Expr *
   fillInlineAsmTypeInfo(Context, Result.get()->getType(), Info);
 
   // Fields are "variables" as far as inline assembly is concerned.
-  Info.setKindVariable();
+  Info.IsVarDecl = true;
 
   return Result;
 }

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=309004=309003=309004=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Jul 25 12:17:32 2017
@@ -42,7 +42,7 @@ void t5(void) {
 void t6(void) {
   __asm int 0x2c
 // CHECK: t6
-// CHECK: call void asm sideeffect inteldialect "int $$44", 
"~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$0x2c", 
"~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t7() {
@@ -61,7 +61,7 @@ void t7() {
 mov eax, ebx
   }
 // CHECK: t7
-// CHECK: call void asm sideeffect inteldialect "int $$44", 
"~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "int $$0x2cU", 
"~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "", 
"~{dirflag},~{fpsr},~{flags}"()
 // CHECK: call void asm sideeffect inteldialect "mov eax, ebx", 
"~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -94,7 +94,7 @@ void t9() {
 // CHECK: t9
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$7
+// CHECK-SAME: mov ebx, $$0x07
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -265,7 +265,7 @@ void t21() {
 // CHECK: t21
 // CHECK: call void asm sideeffect inteldialect
 // CHECK-SAME: push ebx
-// CHECK-SAME: mov ebx, $$7
+// CHECK-SAME: mov ebx, $$07H
 // CHECK-SAME: pop ebx
 // CHECK-SAME: "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
@@ -312,13 +312,13 @@ void t24() {
 void t25() {
 // CHECK: t25
   __asm mov eax, 0h
-// CHECK: mov eax, $$4294967295
+// CHECK: mov eax, $$0h
   __asm mov eax, 0fhU
 // CHECK: mov eax, $$15
   __asm mov eax, 0a2h
-// CHECK: mov eax, $$162
+// CHECK: mov eax, $$0a2h
   __asm mov eax, 10100010b
-// CHECK: mov eax, $$162
+// CHECK: mov eax, $$10100010b
   __asm mov eax, 10100010BU
 // CHECK: mov eax, $$162
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()

Removed: cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp?rev=309003=auto
==
--- cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (original)
+++ cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (removed)
@@ -1,60 +0,0 @@
-// REQUIRES: 

Re: [PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Nico Weber via cfe-commits
On Tue, Jul 25, 2017 at 2:53 PM, Joerg Sonnenberger  wrote:

> On Sun, Jul 23, 2017 at 07:06:25PM -0400, Nico Weber via cfe-commits wrote:
> > If you need this behavior for something, that sounds like something a
> > -nodefaultlibs++ could do. -nostdlib++ is really meant to disable the c++
> > stdlib and nothing else.
>
> But the -lm is only there because -lc++ alone (or -lstdc++ for that
> matter) wouldn't really work.
>

Do you have a reference for that? Several toolchains link in -lm in C mode
even.


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


Re: [PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Joerg Sonnenberger via cfe-commits
On Sun, Jul 23, 2017 at 07:06:25PM -0400, Nico Weber via cfe-commits wrote:
> If you need this behavior for something, that sounds like something a
> -nodefaultlibs++ could do. -nostdlib++ is really meant to disable the c++
> stdlib and nothing else.

But the -lm is only there because -lc++ alone (or -lstdc++ for that
matter) wouldn't really work.

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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D28691#820466, @b-sumner wrote:

> Can we drop the "opencl" part of the name and use something like 
> __scoped_atomic_*?   Also, it may not make sense to support non-constant 
> scope here since we can't predict what other scopes may be added by other 
> languages in the future.


we could use the approach of LangAS, i.e. we allow targets to map all language 
specific scopes to target-specific scope names, since IR only cares about scope 
names, which are target specific. And this is what the current implementation 
does.

I have no objection to use the __scoped_atomic_ name. It is more general and 
extensible. John/Anastasia, any comments? Thanks.


https://reviews.llvm.org/D28691



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-25 Thread Lang Hames via Phabricator via cfe-commits
lhames accepted this revision.
lhames added a comment.
This revision is now accepted and ready to land.

Otherwise this looks good to me.




Comment at: examples/clang-interpreter/CMakeLists.txt:73
+set_property(TARGET ${TARGET} PROPERTY COMPILE_FLAGS ${editedFlags})
+#message("COMPILE_FLAGS: '${addedFlags}' '${editedFlags}'")
+

These debugging messages (this and the one below) should probably be stripped.



Comment at: examples/clang-interpreter/Invoke.h:10
+
+#pragma once
+

I believe you should use include guards in LLVM headers. Pragma once should 
work, but I don't think it's standard (and it doesn't seem to be used anywhere 
else in the codebase).



Comment at: examples/clang-interpreter/Manager.h:10
+
+#pragma once
+

Ditto here.


https://reviews.llvm.org/D35103



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 108127.
yaxunl added a comment.

Add min/max and missing file.


https://reviews.llvm.org/D28691

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/SyncScope.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/StmtPrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-ops.cl
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+
+// Basic parsing/Sema tests for __opencl_atomic_*
+
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+
+struct S { char c[3]; };
+
+char i8;
+short i16;
+int i32;
+int8 i64;
+
+atomic_int gn;
+
+void f(atomic_int *i, const atomic_int *ci,
+   atomic_intptr_t *p, atomic_float *d,
+   int *I, const int *CI,
+   intptr_t *P, float *D, struct S *s1, struct S *s2,
+   global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
+   constant atomic_int *i_c) {
+  __opencl_atomic_init(I, 5); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __opencl_atomic_load(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+  __opencl_atomic_store(0,0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
+  __opencl_atomic_store((int *)0, 0, 0, 0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_store(i, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(ci, 0, memory_order_relaxed, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+  __opencl_atomic_store(i_g, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_l, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_p, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_c, 0, memory_order_relaxed, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+
+  int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
+
+  __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

In https://reviews.llvm.org/D28691#820375, @kzhuravl wrote:

> Seems like SyncScope.h file is missing?


Right. I will add it.


https://reviews.llvm.org/D28691



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


[PATCH] D35849: [UBSan] Provide default blacklist filename for UBSan

2017-07-25 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a reviewer: vsk.
vsk added a comment.

This won't do the right thing if more than one sanitizer with a default 
blacklist is enabled. It's also problematic that a default blacklist for one 
sanitizer can blacklist code for a different sanitizer. See:

https://reviews.llvm.org/D32043
https://reviews.llvm.org/D32047
https://reviews.llvm.org/D32842

IMO I think https://reviews.llvm.org/D32842 is the right path forward. I don't 
have the time to get back to it this week, but if you'd like to pick it up and 
respond to review feedback from @eugenis, please do (I can certainly help with 
the review).


https://reviews.llvm.org/D35849



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


[PATCH] D35849: [UBSan] Provide default blacklist filename for UBSan

2017-07-25 Thread Han Shen via Phabricator via cfe-commits
shenhan created this revision.

This is to provide a default blacklist filename for UBSan.

While UBSan is turned on, it's better that clang pick up a blacklist file (when 
exists), just as what ASan / MSan does, so we do not end up adding the 
"-fsanitize-blacklist" option to every command line.


https://reviews.llvm.org/D35849

Files:
  lib/Driver/SanitizerArgs.cpp


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -100,6 +100,8 @@
 BlacklistFile = "dfsan_abilist.txt";
   else if (Kinds & CFI)
 BlacklistFile = "cfi_blacklist.txt";
+  else if (Kinds & Undefined)
+BlacklistFile = "ubsan_blacklist.txt";
 
   if (BlacklistFile) {
 clang::SmallString<64> Path(D.ResourceDir);


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -100,6 +100,8 @@
 BlacklistFile = "dfsan_abilist.txt";
   else if (Kinds & CFI)
 BlacklistFile = "cfi_blacklist.txt";
+  else if (Kinds & Undefined)
+BlacklistFile = "ubsan_blacklist.txt";
 
   if (BlacklistFile) {
 clang::SmallString<64> Path(D.ResourceDir);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Nico Weber via cfe-commits
The test also fails on many other bots on http://lab.llvm.org:8011/console
, a short excerpt:

http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/9702/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/1940/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/5197/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Ax86-ms-inline-asm-enum_feature.cpp

On Tue, Jul 25, 2017 at 1:52 PM, Kostya Serebryany via Phabricator via
cfe-commits  wrote:

> kcc added a comment.
>
> Hi.
> This patch causes the msan bots to complain. Please fix or revert ASAP.
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
> Testing: 0 .. 10..
> FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)
>
> - TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 
>
> Script:
> ---
>
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm_build_msan/./bin/clang -cc1 -internal-isystem
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm_build_msan/lib/clang/6.0.0/include -nostdsysteminc -triple
> x86_64-pc-win32 -fasm-blocks -emit-llvm /mnt/b/sanitizer-buildbot3/
> sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
> -o - | /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm_build_msan/./bin/FileCheck /mnt/b/sanitizer-buildbot3/
> sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/
> CodeGen/ms_this.cpp
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
>
> Exit Code: 2
>
> Command Output (stderr):
> 
>
> 4713==WARNING: MemorySanitizer: use-of-uninitialized-value
> --
>
>   #0 0x3143ba3 in (anonymous namespace)::X86AsmParser::
> ParseIntelIdentifier(llvm::MCExpr const*&, llvm::StringRef&,
> llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
>   #1 0x313f288 in (anonymous namespace)::X86AsmParser::
> ParseIntelExpression((anonymous 
> namespace)::X86AsmParser::IntelExprStateMachine&,
> llvm::SMLoc&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
>   #2 0x31389e7 in (anonymous namespace)::X86AsmParser::
> ParseIntelBracExpression(unsigned int, llvm::SMLoc, long, bool, unsigned
> int) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
>   #3 0x31307f8 in ParseIntelOperand /mnt/b/sanitizer-buildbot3/
> sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/
> AsmParser/X86AsmParser.cpp:1961:12
>   #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand()
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
>   #5 0x3118cda in (anonymous namespace)::X86AsmParser::
> ParseInstruction(llvm::ParseInstructionInfo&, llvm::StringRef,
> llvm::SMLoc, 
> llvm::SmallVectorImpl std::__1::default_delete > >&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2510:44
>   #6 0x4bb9a48 in (anonymous namespace)::AsmParser::parseStatement((anonymous
> namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/
> build/llvm/lib/MC/MCParser/AsmParser.cpp:2034:42
>   #7 0x4ba63a3 in (anonymous namespace)::AsmParser::parseMSInlineAsm(void*,
> std::__1::basic_string std::__1::allocator >&, unsigned int&, unsigned int&,
> llvm::SmallVectorImpl >&,
> llvm::SmallVectorImpl std::__1::char_traits, std::__1::allocator > >&,
> llvm::SmallVectorImpl std::__1::char_traits, std::__1::allocator > >&,
> llvm::MCInstrInfo const*, llvm::MCInstPrinter const*,
> llvm::MCAsmParserSemaCallback&) 

[PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r308997, thanks!


https://reviews.llvm.org/D35780



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


[PATCH] D35383: [coroutines] Add serialization/deserialization of coroutines

2017-07-25 Thread Gor Nishanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
GorNishanov marked an inline comment as done.
Closed by commit rL308996: [coroutines] Add serialization/deserialization of 
coroutines (authored by GorNishanov).

Changed prior to commit:
  https://reviews.llvm.org/D35383?vs=108111=108121#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35383

Files:
  cfe/trunk/include/clang/AST/StmtCXX.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/StmtCXX.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/test/PCH/coroutines.cpp

Index: cfe/trunk/include/clang/AST/StmtCXX.h
===
--- cfe/trunk/include/clang/AST/StmtCXX.h
+++ cfe/trunk/include/clang/AST/StmtCXX.h
@@ -317,6 +317,7 @@
   unsigned NumParams;
 
   friend class ASTStmtReader;
+  friend class ASTReader;
   friend TrailingObjects;
 
   Stmt **getStoredStmts() { return getTrailingObjects(); }
@@ -347,6 +348,8 @@
 
 public:
   static CoroutineBodyStmt *Create(const ASTContext , CtorArgs const );
+  static CoroutineBodyStmt *Create(const ASTContext , EmptyShell,
+   unsigned NumParams);
 
   bool hasDependentPromiseType() const {
 return getPromiseDecl()->getType()->isDependentType();
@@ -444,6 +447,8 @@
 SubStmts[SubStmt::PromiseCall] = PromiseCall;
   }
 
+  CoreturnStmt(EmptyShell) : CoreturnStmt({}, {}, {}) {}
+
   SourceLocation getKeywordLoc() const { return CoreturnLoc; }
 
   /// \brief Retrieve the operand of the 'co_return' statement. Will be nullptr
Index: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
===
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h
@@ -1545,9 +1545,14 @@
 
   // ARC
   EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
-  
+
   STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-  EXPR_LAMBDA // LambdaExpr
+  EXPR_LAMBDA,// LambdaExpr
+  STMT_COROUTINE_BODY,
+  STMT_CORETURN,
+  EXPR_COAWAIT,
+  EXPR_COYIELD,
+  EXPR_DEPENDENT_COAWAIT,
 };
 
 /// \brief The kinds of designators that can occur in a
Index: cfe/trunk/test/PCH/coroutines.cpp
===
--- cfe/trunk/test/PCH/coroutines.cpp
+++ cfe/trunk/test/PCH/coroutines.cpp
@@ -0,0 +1,77 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace std::experimental {
+template  struct coroutine_traits;
+
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_void() noexcept;
+suspend_always yield_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template 
+void f(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_yield 42; // checks coyield_expr
+  co_await x;  // checks dependent_coawait
+  co_return;   // checks coreturn_stmt
+}
+
+template 
+int f2(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_return x;   // checks coreturn_stmt with expr
+}
+
+#else
+
+// expected-no-diagnostics
+void g() {
+  f(suspend_always{});
+  f2(42);
+}
+
+#endif
Index: cfe/trunk/lib/AST/StmtCXX.cpp
===
--- cfe/trunk/lib/AST/StmtCXX.cpp
+++ cfe/trunk/lib/AST/StmtCXX.cpp
@@ -96,6 +96,20 @@
   return new (Mem) CoroutineBodyStmt(Args);
 }
 
+CoroutineBodyStmt *CoroutineBodyStmt::Create(const ASTContext , EmptyShell,
+ 

r308997 - Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Jul 25 11:02:57 2017
New Revision: 308997

URL: http://llvm.org/viewvc/llvm-project?rev=308997=rev
Log:
Introduce -nostdlib++ flag to disable linking the C++ standard library.

Projects that want to statically link their own C++ standard library currently
need to pass -nostdlib or -nodefaultlibs, which also disables linking of the
builtins library, -lm, and so on. Alternatively, they could use `clang` instead
of `clang++`, but that already disables implicit addition of -lm on some
toolchains.

Add a dedicated flag -nostdlib++ that disables just linking of libc++ /
libstdc++. This is analogous to -nostdinc++.

https://reviews.llvm.org/D35780

Added:
cfe/trunk/test/Driver/nostdlibxx.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Ananas.cpp
cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp
cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/DragonFly.cpp
cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
cfe/trunk/lib/Driver/ToolChains/Minix.cpp
cfe/trunk/lib/Driver/ToolChains/NaCl.cpp
cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
cfe/trunk/lib/Driver/ToolChains/PS4CPU.cpp
cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=308997=308996=308997=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Jul 25 11:02:57 2017
@@ -2144,6 +2144,7 @@ def nostdlibinc : Flag<["-"], "nostdlibi
 def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>,
   HelpText<"Disable standard #include directories for the C++ standard 
library">;
 def nostdlib : Flag<["-"], "nostdlib">;
+def nostdlibxx : Flag<["-"], "nostdlib++">;
 def object : Flag<["-"], "object">;
 def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, 
CC1Option, CC1AsOption]>,
   HelpText<"Write output to ">, MetaVarName<"">;

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=308997=308996=308997=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Jul 25 11:02:57 2017
@@ -432,6 +432,10 @@ public:
   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const;
 
+  /// Returns if the C++ standard library should be linked in.
+  /// Note that e.g. -lm should still be linked even if this returns false.
+  bool ShouldLinkCXXStdlib(const llvm::opt::ArgList ) const;
+
   /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use
   /// for the given C++ standard library type.
   virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=308997=308996=308997=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Jul 25 11:02:57 2017
@@ -648,8 +648,16 @@ void ToolChain::AddClangCXXStdlibInclude
   DriverArgs.AddAllArgs(CC1Args, options::OPT_stdlib_EQ);
 }
 
+bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList ) const {
+  return getDriver().CCCIsCXX() &&
+ !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+  options::OPT_nostdlibxx);
+}
+
 void ToolChain::AddCXXStdlibLibArgs(const ArgList ,
 ArgStringList ) const {
+  assert(!Args.hasArg(options::OPT_nostdlibxx) &&
+ "should not have called this");
   CXXStdlibType Type = GetCXXStdlibType(Args);
 
   switch (Type) {

Modified: cfe/trunk/lib/Driver/ToolChains/Ananas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Ananas.cpp?rev=308997=308996=308997=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Ananas.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Ananas.cpp Tue Jul 25 11:02:57 2017
@@ -91,11 +91,10 @@ void ananas::Linker::ConstructJob(Compil
 
   

r308996 - [coroutines] Add serialization/deserialization of coroutines

2017-07-25 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Tue Jul 25 11:01:49 2017
New Revision: 308996

URL: http://llvm.org/viewvc/llvm-project?rev=308996=rev
Log:
[coroutines] Add serialization/deserialization of coroutines

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: EricWF, cfe-commits

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

Added:
cfe/trunk/test/PCH/coroutines.cpp
Modified:
cfe/trunk/include/clang/AST/StmtCXX.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/StmtCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/StmtCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtCXX.h?rev=308996=308995=308996=diff
==
--- cfe/trunk/include/clang/AST/StmtCXX.h (original)
+++ cfe/trunk/include/clang/AST/StmtCXX.h Tue Jul 25 11:01:49 2017
@@ -317,6 +317,7 @@ class CoroutineBodyStmt final
   unsigned NumParams;
 
   friend class ASTStmtReader;
+  friend class ASTReader;
   friend TrailingObjects;
 
   Stmt **getStoredStmts() { return getTrailingObjects(); }
@@ -347,6 +348,8 @@ private:
 
 public:
   static CoroutineBodyStmt *Create(const ASTContext , CtorArgs const );
+  static CoroutineBodyStmt *Create(const ASTContext , EmptyShell,
+   unsigned NumParams);
 
   bool hasDependentPromiseType() const {
 return getPromiseDecl()->getType()->isDependentType();
@@ -444,6 +447,8 @@ public:
 SubStmts[SubStmt::PromiseCall] = PromiseCall;
   }
 
+  CoreturnStmt(EmptyShell) : CoreturnStmt({}, {}, {}) {}
+
   SourceLocation getKeywordLoc() const { return CoreturnLoc; }
 
   /// \brief Retrieve the operand of the 'co_return' statement. Will be nullptr

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=308996=308995=308996=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Tue Jul 25 11:01:49 2017
@@ -1545,9 +1545,14 @@ namespace clang {
 
   // ARC
   EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr
-  
+
   STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-  EXPR_LAMBDA // LambdaExpr
+  EXPR_LAMBDA,// LambdaExpr
+  STMT_COROUTINE_BODY,
+  STMT_CORETURN,
+  EXPR_COAWAIT,
+  EXPR_COYIELD,
+  EXPR_DEPENDENT_COAWAIT,
 };
 
 /// \brief The kinds of designators that can occur in a

Modified: cfe/trunk/lib/AST/StmtCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtCXX.cpp?rev=308996=308995=308996=diff
==
--- cfe/trunk/lib/AST/StmtCXX.cpp (original)
+++ cfe/trunk/lib/AST/StmtCXX.cpp Tue Jul 25 11:01:49 2017
@@ -96,6 +96,20 @@ CoroutineBodyStmt *CoroutineBodyStmt::Cr
   return new (Mem) CoroutineBodyStmt(Args);
 }
 
+CoroutineBodyStmt *CoroutineBodyStmt::Create(const ASTContext , EmptyShell,
+ unsigned NumParams) {
+  std::size_t Size = totalSizeToAlloc(
+  CoroutineBodyStmt::FirstParamMove + NumParams);
+
+  void *Mem = C.Allocate(Size, alignof(CoroutineBodyStmt));
+  auto *Result = new (Mem) CoroutineBodyStmt(CtorArgs());
+  Result->NumParams = NumParams;
+  auto *ParamBegin = Result->getStoredStmts() + SubStmt::FirstParamMove;
+  std::uninitialized_fill(ParamBegin, ParamBegin + NumParams,
+  static_cast(nullptr));
+  return Result;
+}
+
 CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const )
 : Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) {
   Stmt **SubStmts = getStoredStmts();

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=308996=308995=308996=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Tue Jul 25 11:01:49 2017
@@ -367,28 +367,45 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsm
 }
 
 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  assert(Record.peekInt() == S->NumParams);
+  Record.skipInts(1);
+  auto *StoredStmts = S->getStoredStmts();
+  for (unsigned i = 0;
+   i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
+StoredStmts[i] = Record.readSubStmt();
 }
 
 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+ 

[PATCH] D33277: [Clang][x86][Inline Asm] - Enum support for MS syntax

2017-07-25 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

Hi. 
This patch causes the msan bots to complain. Please fix or revert ASAP. 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/6702/steps/check-clang%20msan/logs/stdio
Testing: 0 .. 10..
FAIL: Clang :: CodeGen/ms_this.cpp (2142 of 11057)

- TEST 'Clang :: CodeGen/ms_this.cpp' FAILED 

Script:
---

/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/clang
 -cc1 -internal-isystem 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/clang/6.0.0/include
 -nostdsysteminc -triple x86_64-pc-win32 -fasm-blocks -emit-llvm 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
 -o - | 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CodeGen/ms_this.cpp
--

Exit Code: 2

Command Output (stderr):


4713==WARNING: MemorySanitizer: use-of-uninitialized-value
--

  #0 0x3143ba3 in (anonymous 
namespace)::X86AsmParser::ParseIntelIdentifier(llvm::MCExpr const*&, 
llvm::StringRef&, llvm::InlineAsmIdentifierInfo&, bool, llvm::SMLoc&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1664:7
  #1 0x313f288 in (anonymous 
namespace)::X86AsmParser::ParseIntelExpression((anonymous 
namespace)::X86AsmParser::IntelExprStateMachine&, llvm::SMLoc&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1440:13
  #2 0x31389e7 in (anonymous 
namespace)::X86AsmParser::ParseIntelBracExpression(unsigned int, llvm::SMLoc, 
long, bool, unsigned int) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1555:7
  #3 0x31307f8 in ParseIntelOperand 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1961:12
  #4 0x31307f8 in (anonymous namespace)::X86AsmParser::ParseOperand() 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1225
  #5 0x3118cda in (anonymous 
namespace)::X86AsmParser::ParseInstruction(llvm::ParseInstructionInfo&, 
llvm::StringRef, llvm::SMLoc, 
llvm::SmallVectorImpl >&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:2510:44
  #6 0x4bb9a48 in (anonymous namespace)::AsmParser::parseStatement((anonymous 
namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/MC/MCParser/AsmParser.cpp:2034:42
  #7 0x4ba63a3 in (anonymous namespace)::AsmParser::parseMSInlineAsm(void*, 
std::__1::basic_string&, unsigned int&, unsigned int&, 
llvm::SmallVectorImpl >&, 
llvm::SmallVectorImpl >&, 
llvm::SmallVectorImpl >&, llvm::MCInstrInfo const*, llvm::MCInstPrinter 
const*, llvm::MCAsmParserSemaCallback&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/MC/MCParser/AsmParser.cpp:5343:25
  #8 0x82f1100 in 
clang::Parser::ParseMicrosoftAsmStatement(clang::SourceLocation) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmtAsm.cpp:619:15
  #9 0x82f6310 in clang::Parser::ParseAsmStatement(bool&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmtAsm.cpp:682:12
  #10 0x82d15d9 in 
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, 
clang::Parser::ParsedAttributesWithRange&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:277:11
  #11 0x82cfff1 in 
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) 

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Seems like SyncScope.h file is missing?


https://reviews.llvm.org/D28691



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


[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-07-25 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann created this revision.
euhlmann added a project: clang.

Change 272124* introduced a regression in spaceRequiredBetween for left aligned 
pointers to decltype and typeof expressions. This fix adds logic to fix this. 
The test added is based on a related test in determineStarAmpUsage. Also add 
test cases for the regression.

- http://llvm.org/viewvc/llvm-project?view=revision=272124

LLVM bug tracker: https://bugs.llvm.org/show_bug.cgi?id=30407


https://reviews.llvm.org/D35847

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5351,6 +5351,9 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5397,9 +5400,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2202,7 +2202,10 @@
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
   if (Right.is(TT_PointerOrReference))
-return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
+return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl &&
+!(Left.MatchingParen && Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->isOneOf(tok::kw_typeof,
+tok::kw_decltype))) ||
(Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
  Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5351,6 +5351,9 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5397,9 +5400,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2202,7 +2202,10 @@
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
   if (Right.is(TT_PointerOrReference))
-return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
+return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl &&
+!(Left.MatchingParen && Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->isOneOf(tok::kw_typeof,
+tok::kw_decltype))) ||
(Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
  Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35780: Introduce -nostdlib++ flag to disable linking the C++ standard library.

2017-07-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

This seems reasonable to me.




Comment at: lib/Driver/ToolChain.cpp:660
+  assert(!Args.hasArg(options::OPT_nostdlibxx) &&
+ "should not have called this");
   CXXStdlibType Type = GetCXXStdlibType(Args);

The message here doesn't really add any info. I think asserting without a 
message in this case is fine.


https://reviews.llvm.org/D35780



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


[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308990: [analyzer] Add diagnostic text for generalized 
refcount annotations. (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D35613?vs=107471=108115#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35613

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/test/Analysis/retain-release-inline.m
  cfe/trunk/test/Analysis/retain-release.m

Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
@@ -145,9 +145,11 @@
 /// Indicates that the tracked object is an Objective-C object.
 ObjC,
 /// Indicates that the tracked object could be a CF or Objective-C object.
-AnyObj
+AnyObj,
+/// Indicates that the tracked object is a generalized object.
+Generalized
   };
-  
+
 private:
   Kind K;
   ObjKind O;
Index: cfe/trunk/test/Analysis/retain-release-inline.m
===
--- cfe/trunk/test/Analysis/retain-release-inline.m
+++ cfe/trunk/test/Analysis/retain-release-inline.m
@@ -299,15 +299,15 @@
   bar(s);
 }
 
-__attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
 void free(void *);
 
 // As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
 // implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
 // a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
 // count of 'bmap' along the path in 'isl_basic_map_free' assuming the predicate of the second 'if' branch to be
 // true or assuming both the predicates in the function to be false.
-__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   if (!bmap)
 return NULL;
 
@@ -322,15 +322,15 @@
 // implementation and doesn't analyze its body. If that annotation is removed, a 'use-after-release' warning might
 // be raised by RetainCountChecker as the pointer which is passed as an argument to this function and the pointer
 // which is returned from the function point to the same memory location.
-__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap) {
+__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap) {
   if (!bmap)
 return NULL;
 
   bmap->ref++;
   return bmap;
 }
 
-void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   // After this call, 'bmap' has a +1 reference count.
   bmap = isl_basic_map_cow(bmap);
   // After the call to 'isl_basic_map_copy', 'bmap' has a +1 reference count.
@@ -341,7 +341,7 @@
   isl_basic_map_free(temp);
 }
 
-void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) {
   // After this call, 'bmap' has a +1 reference count.
   bmap = isl_basic_map_cow(bmap); // no-warning
   // After this call, 'bmap' has a +0 reference count.
Index: cfe/trunk/test/Analysis/retain-release.m
===
--- cfe/trunk/test/Analysis/retain-release.m
+++ cfe/trunk/test/Analysis/retain-release.m
@@ -325,6 +325,9 @@
 
 extern
 void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
+typedef struct {
+  int ref;
+} isl_basic_map;
 
 //===--===//
 // Test cases.
@@ -574,6 +577,14 @@
   }
 }
 
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
+
+// 

[PATCH] D35383: [coroutines] Add serialization/deserialization of coroutines

2017-07-25 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov updated this revision to Diff 108111.
GorNishanov added a comment.

Thank you for the review. Feedback implemented. Preparing to land


https://reviews.llvm.org/D35383

Files:
  include/clang/AST/StmtCXX.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtCXX.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/PCH/coroutines.cpp

Index: test/PCH/coroutines.cpp
===
--- /dev/null
+++ test/PCH/coroutines.cpp
@@ -0,0 +1,77 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace std::experimental {
+template  struct coroutine_traits;
+
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_void() noexcept;
+suspend_always yield_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template 
+void f(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_yield 42; // checks coyield_expr
+  co_await x;  // checks dependent_coawait
+  co_return;   // checks coreturn_stmt
+}
+
+template 
+int f2(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_return x;   // checks coreturn_stmt with expr
+}
+
+#else
+
+// expected-no-diagnostics
+void g() {
+  f(suspend_always{});
+  f2(42);
+}
+
+#endif
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -286,7 +286,7 @@
   }
 
   // Outputs
-  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {  
+  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
 Record.AddStmt(S->getOutputExpr(I));
 Record.AddString(S->getOutputConstraint(I));
   }
@@ -300,29 +300,48 @@
   Code = serialization::STMT_MSASM;
 }
 
-void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) {
+  VisitStmt(CoroStmt);
+  Record.push_back(CoroStmt->getParamMoves().size());
+  for (Stmt *S : CoroStmt->children())
+Record.AddStmt(S);
+  Code = serialization::STMT_COROUTINE_BODY;
 }
 
 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  Record.AddSourceLocation(S->getKeywordLoc());
+  Record.AddStmt(S->getOperand());
+  Record.AddStmt(S->getPromiseCall());
+  Record.push_back(S->isImplicit());
+  Code = serialization::STMT_CORETURN;
 }
 
-void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) {
+  VisitExpr(E);
+  Record.AddSourceLocation(E->getKeywordLoc());
+  for (Stmt *S : E->children())
+Record.AddStmt(S);
+  Record.AddStmt(E->getOpaqueValue());
 }
 
-void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) {
+  VisitCoroutineSuspendExpr(E);
+  Record.push_back(E->isImplicit());
+  Code = serialization::EXPR_COAWAIT;
+}
+
+void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) {
+  VisitCoroutineSuspendExpr(E);
+  Code = serialization::EXPR_COYIELD;
 }
 
-void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void 

r308990 - [analyzer] Add diagnostic text for generalized refcount annotations.

2017-07-25 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Jul 25 10:17:09 2017
New Revision: 308990

URL: http://llvm.org/viewvc/llvm-project?rev=308990=rev
Log:
[analyzer] Add diagnostic text for generalized refcount annotations.

Add a 'Generalized' object kind to the retain-count checker and suitable
generic diagnostic text for retain-count diagnostics involving those objects.

For now the object kind is introduced in summaries by 'annotate' attributes.
Once we have more experience with these annotations we will propose explicit
attributes.

Patch by Malhar Thakkar!

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release-inline.m
cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h?rev=308990=308989=308990=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h Tue Jul 
25 10:17:09 2017
@@ -145,9 +145,11 @@ public:
 /// Indicates that the tracked object is an Objective-C object.
 ObjC,
 /// Indicates that the tracked object could be a CF or Objective-C object.
-AnyObj
+AnyObj,
+/// Indicates that the tracked object is a generalized object.
+Generalized
   };
-  
+
 private:
   Kind K;
   ObjKind O;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=308990=308989=308990=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Tue Jul 25 
10:17:09 2017
@@ -1340,6 +1340,8 @@ RetainSummaryManager::getRetEffectFromAn
 
   if (D->hasAttr())
 return RetEffect::MakeOwned(RetEffect::CF);
+  else if (hasRCAnnotation(D, "rc_ownership_returns_retained"))
+return RetEffect::MakeOwned(RetEffect::Generalized);
 
   if (D->hasAttr())
 return RetEffect::MakeNotOwned(RetEffect::CF);
@@ -1363,9 +1365,11 @@ RetainSummaryManager::updateSummaryFromA
 const ParmVarDecl *pd = *pi;
 if (pd->hasAttr())
   Template->addArg(AF, parm_idx, DecRefMsg);
-else if (pd->hasAttr())
+else if (pd->hasAttr() ||
+ hasRCAnnotation(pd, "rc_ownership_consumed"))
   Template->addArg(AF, parm_idx, DecRef);
-else if (pd->hasAttr()) {
+else if (pd->hasAttr() ||
+ hasRCAnnotation(pd, "rc_ownership_returns_retained")) {
   QualType PointeeTy = pd->getType()->getPointeeType();
   if (!PointeeTy.isNull())
 if (coreFoundation::isCFObjectRef(PointeeTy))
@@ -1999,17 +2003,15 @@ CFRefReportVisitor::VisitNode(const Expl
   }
 
   if (CurrV.getObjKind() == RetEffect::CF) {
-if (Sym->getType().isNull()) {
-  os << " returns a Core Foundation object with a ";
-} else {
-  os << " returns a Core Foundation object of type "
- << Sym->getType().getAsString() << " with a ";
-}
-  }
-  else {
+os << " returns a Core Foundation object of type "
+   << Sym->getType().getAsString() << " with a ";
+  } else if (CurrV.getObjKind() == RetEffect::Generalized) {
+os << " returns an object of type " << Sym->getType().getAsString()
+   << " with a ";
+  } else {
 assert (CurrV.getObjKind() == RetEffect::ObjC);
 QualType T = Sym->getType();
-if (T.isNull() || !isa(T)) {
+if (!isa(T)) {
   os << " returns an Objective-C object with a ";
 } else {
   const ObjCObjectPointerType *PT = cast(T);

Modified: cfe/trunk/test/Analysis/retain-release-inline.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release-inline.m?rev=308990=308989=308990=diff
==
--- cfe/trunk/test/Analysis/retain-release-inline.m (original)
+++ cfe/trunk/test/Analysis/retain-release-inline.m Tue Jul 25 10:17:09 2017
@@ -299,7 +299,7 @@ void test_neg() {
   bar(s);
 }
 
-__attribute__((cf_returns_retained)) isl_basic_map 
*isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+__attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map 
*isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) 
isl_basic_map *bmap);
 void free(void *);
 
 // As 'isl_basic_map_free' is annotated with 
'rc_ownership_trusted_implementation', RetainCountChecker trusts its
@@ -307,7 +307,7 @@ void free(void *);
 // a leak 

[PATCH] D35824: [Sema] Implicitly apply the may_alias attribute to std::byte

2017-07-25 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: test/CodeGenCXX/std-byte.cpp:7
+enum byte : unsigned char {};
+}
+

Would it be worth adding an explicit test that `::byte`, `::my::byte`, 
`::my::std::byte` are or are not handled in the same way?


https://reviews.llvm.org/D35824



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


Re: r308897 - Work around an MSVC2017 update 3 codegen bug.

2017-07-25 Thread Hans Wennborg via cfe-commits
r308988. Thanks!

On Mon, Jul 24, 2017 at 9:55 AM, Nico Weber  wrote:
> We probably want this in 5.0.
>
> On Mon, Jul 24, 2017 at 12:54 PM, Nico Weber via cfe-commits
>  wrote:
>>
>> Author: nico
>> Date: Mon Jul 24 09:54:11 2017
>> New Revision: 308897
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=308897=rev
>> Log:
>> Work around an MSVC2017 update 3 codegen bug.
>>
>> C2017 update 3 produces a clang that crashes when compiling clang.
>> Disabling
>> optimizations for StmtProfiler::VisitCXXOperatorCallExpr() makes the crash
>> go
>> away.
>>
>> Patch from Bruce Dawson !
>> https://reviews.llvm.org/D35757
>>
>> Modified:
>> cfe/trunk/lib/AST/StmtProfile.cpp
>>
>> Modified: cfe/trunk/lib/AST/StmtProfile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=308897=308896=308897=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/StmtProfile.cpp (original)
>> +++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Jul 24 09:54:11 2017
>> @@ -1412,6 +1412,15 @@ static Stmt::StmtClass DecodeOperatorCal
>>llvm_unreachable("Invalid overloaded operator expression");
>>  }
>>
>> +#if defined(_MSC_VER)
>> +#if _MSC_VER == 1911
>> +// Work around
>> https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
>> +// MSVC 2017 update 3 miscompiles this function, and a clang built with
>> it
>> +// will crash in stage 2 of a bootstrap build.
>> +#pragma optimize("", off)
>> +#endif
>> +#endif
>> +
>>  void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S)
>> {
>>if (S->isTypeDependent()) {
>>  // Type-dependent operator calls are profiled like their underlying
>> @@ -1444,6 +1453,12 @@ void StmtProfiler::VisitCXXOperatorCallE
>>ID.AddInteger(S->getOperator());
>>  }
>>
>> +#if defined(_MSC_VER)
>> +#if _MSC_VER == 1911
>> +#pragma optimize("", on)
>> +#endif
>> +#endif
>> +
>>  void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
>>VisitCallExpr(S);
>>  }
>>
>>
>> ___
>> 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


[PATCH] D35674: [analyzer] Treat C++ throw as sink during CFG-based suppress-on-sink.

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Do we have a radar for this? It sounds familiar.




Comment at: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp:3313
 
+static bool isNoReturnBlock(const CFGBlock *Blk) {
+  if (Blk->hasNoReturnElement())

Maybe a better name for this would be "treatAsSink"? This way people won't use 
it as short-hand for whether the block has a no-return element.


Repository:
  rL LLVM

https://reviews.llvm.org/D35674



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


[PATCH] D35824: [Sema] Implicitly apply the may_alias attribute to std::byte

2017-07-25 Thread David Majnemer via Phabricator via cfe-commits
majnemer updated this revision to Diff 108105.
majnemer added a comment.

- Address review feedback.


https://reviews.llvm.org/D35824

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  test/CodeGenCXX/std-byte.cpp


Index: test/CodeGenCXX/std-byte.cpp
===
--- /dev/null
+++ test/CodeGenCXX/std-byte.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm 
-O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  // PATH: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  // PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -85,6 +85,12 @@
 return TypeHasMayAlias(TTy->desugar());
   }
 
+  // C++1z [intro.object]p3: If a complete object is created in storage
+  // associated with another object e of type [...] "array of N std::byte", 
that
+  // array provides storage for the created object [...].
+  if (QTy->isStdByteType())
+return true;
+
   return false;
 }
 
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2313,6 +2313,15 @@
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+  return true;
+  }
+  return false;
+}
+
 bool Type::isPromotableIntegerType() const {
   if (const BuiltinType *BT = getAs())
 switch (BT->getKind()) {
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1752,6 +1752,7 @@
   bool isTemplateTypeParmType() const;  // C++ template type parameter
   bool isNullPtrType() const;   // C++11 std::nullptr_t
   bool isAlignValT() const; // C++17 std::align_val_t
+  bool isStdByteType() const;   // C++17 std::byte
   bool isAtomicType() const;// C11 _Atomic()
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \


Index: test/CodeGenCXX/std-byte.cpp
===
--- /dev/null
+++ test/CodeGenCXX/std-byte.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-passes -o - %s | FileCheck %s
+
+// std::byte should be considered equivalent to char for aliasing.
+
+namespace std {
+enum byte : unsigned char {};
+}
+
+void test0(std::byte *sb, int *i) {
+  // CHECK: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  // PATH: store i8 0, i8* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
+  *sb = std::byte{0};
+
+  // CHECK: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  // PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
+  *i = 1;
+}
+
+// CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
+// CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
+// CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
+// CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
+// CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -85,6 +85,12 @@
 return TypeHasMayAlias(TTy->desugar());
   }
 
+  // C++1z [intro.object]p3: If a complete object is created in storage
+  // associated with another object e of type [...] "array of N std::byte", that
+  // array provides storage for the created object [...].
+  if (QTy->isStdByteType())
+return true;
+
   return false;
 }
 
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2313,6 +2313,15 @@
   return false;
 }
 
+bool Type::isStdByteType() const {
+  if (auto *ET = getAs()) {
+auto *II = ET->getDecl()->getIdentifier();
+if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
+ 

r308985 - This test case is causing all PPC and SystemZ bots to remain red.

2017-07-25 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Tue Jul 25 10:04:12 2017
New Revision: 308985

URL: http://llvm.org/viewvc/llvm-project?rev=308985=rev
Log:
This test case is causing all PPC and SystemZ bots to remain red.

Notifying the author via Diffusion did not yield any answer. Therefore, I'm
adding the missing triple. I have no idea if this is the intended triple, but
it seems to fit the bill and should turn the bots back to green.
If the intended triple is a different one, please feel free to change it but I
need make this change to turn the bots back to green now.

Modified:
cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp

Modified: cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp?rev=308985=308984=308985=diff
==
--- cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp (original)
+++ cfe/trunk/test/CodeGen/x86-ms-inline-asm-enum_feature.cpp Tue Jul 25 
10:04:12 2017
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fasm-blocks -emit-llvm -o - | 
FileCheck %s
 namespace x {
 enum { A = 12 };
 struct y_t {


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


[PATCH] D33676: Place implictly declared functions at block scope

2017-07-25 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

Ping.


https://reviews.llvm.org/D33676



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


[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2017-07-25 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

In https://reviews.llvm.org/D34030#819699, @MontyKutyi wrote:

> As I can see the `clang/test` contains a lot of different simple tests, but 
> for testing this I think it is not enough to run the clang with some 
> arguments on a specific input.  So I should create a new executable which 
> uses the postorder mode of the RecursiveASTVisitor.  Am I right or is there 
> another preferred way for doing this?


The place you're looking for here is in unittests. For example, see 
unittests/AST/PostOrderASTVisitor.cpp.


https://reviews.llvm.org/D34030



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


[PATCH] D34878: [ARM] Option for reading thread pointer from coprocessor register

2017-07-25 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

If there's a precedence for a flag name there, it's nice to be compatible here. 
You don't necessarily need to use the same name as the backend.


https://reviews.llvm.org/D34878



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


[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Sorry for the delay! This looks good to me.

We have a really embarrassing FIXMELATER from 2012 (!!!) that disabled the 
plist tests for diagnostics. This means we're not getting testing for the 
diagnostic text itself. Let's not block this patch on fixing that, though.


Repository:
  rL LLVM

https://reviews.llvm.org/D35613



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


[PATCH] D35613: Add Support for Generic Reference Counting Annotations in RetainCountChecker

2017-07-25 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I will commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D35613



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


r308979 - [OPENMP] Codegen for 'task_reduction' clause.

2017-07-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul 25 08:53:26 2017
New Revision: 308979

URL: http://llvm.org/viewvc/llvm-project?rev=308979=rev
Log:
[OPENMP] Codegen for 'task_reduction' clause.

Added codegen for taskgroup directive with task_reduction clause.
```

```
The next code is emitted:
```
%struct.kmp_task_red_input_t red_init[n];
void *td;
call void @__kmpc_taskgroup(%ident_t id, i32 gtid)
...
red_init[i].shar = &;
red_init[i].size = sizeof();
red_init[i].init = (void*)initializer_function;
red_init[i].fini = (void*)destructor_function;
red_init[i].comb = (void*)combiner_function;
red_init[i].flags = flags;
...
td = call i8* @__kmpc_task_reduction_init(i32 gtid, i32 n, i8*
(void*)red_init);
call void @__kmpc_end_taskgroup(%ident_t id, i32 gtid)

void initializer_function(i8* priv) {
  *(*)priv = ;
  ret void;
}

void destructor_function(i8* priv) {
  (*)priv->~();
  ret void;
}

void combiner_function(i8* inout, i8* in) {
  *(*)inout = *(*)inout  *(*)in;
  ret void;
}
```

Added:
cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=308979=308978=308979=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Jul 25 08:53:26 2017
@@ -1912,7 +1912,7 @@ class OMPTaskgroupDirective : public OMP
   OMPTaskgroupDirective(SourceLocation StartLoc, SourceLocation EndLoc,
 unsigned NumClauses)
   : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, 
OMPD_taskgroup,
-   StartLoc, EndLoc, NumClauses, 1) {}
+   StartLoc, EndLoc, NumClauses, 2) {}
 
   /// Build an empty directive.
   /// \param NumClauses Number of clauses.
@@ -1920,7 +1920,12 @@ class OMPTaskgroupDirective : public OMP
   explicit OMPTaskgroupDirective(unsigned NumClauses)
   : OMPExecutableDirective(this, OMPTaskgroupDirectiveClass, 
OMPD_taskgroup,
SourceLocation(), SourceLocation(), NumClauses,
-   1) {}
+   2) {}
+
+  /// Sets the task_reduction return variable.
+  void setReductionRef(Expr *RR) {
+*std::next(child_begin(), 1) = RR;
+  }
 
 public:
   /// Creates directive.
@@ -1930,10 +1935,12 @@ public:
   /// \param EndLoc Ending Location of the directive.
   /// \param Clauses List of clauses.
   /// \param AssociatedStmt Statement, associated with the directive.
+  /// \param ReductionRef Reference to the task_reduction return variable.
   ///
   static OMPTaskgroupDirective *
   Create(const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc,
- ArrayRef Clauses, Stmt *AssociatedStmt);
+ ArrayRef Clauses, Stmt *AssociatedStmt,
+ Expr *ReductionRef);
 
   /// Creates an empty directive.
   ///
@@ -1943,6 +1950,15 @@ public:
   static OMPTaskgroupDirective *CreateEmpty(const ASTContext ,
 unsigned NumClauses, EmptyShell);
 
+
+  /// Returns reference to the task_reduction return variable.
+  const Expr *getReductionRef() const {
+return static_cast(*std::next(child_begin(), 1));
+  }
+  Expr *getReductionRef() {
+return static_cast(*std::next(child_begin(), 1));
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == OMPTaskgroupDirectiveClass;
   }

Modified: cfe/trunk/lib/AST/StmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtOpenMP.cpp?rev=308979=308978=308979=diff
==
--- cfe/trunk/lib/AST/StmtOpenMP.cpp (original)
+++ cfe/trunk/lib/AST/StmtOpenMP.cpp Tue Jul 25 08:53:26 2017
@@ -524,14 +524,15 @@ OMPTaskwaitDirective *OMPTaskwaitDirecti
 
 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
 const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc,
-ArrayRef Clauses, Stmt *AssociatedStmt) {
+ArrayRef Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
   unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
 sizeof(OMPClause *) * Clauses.size(),
 alignof(Stmt *));
-  void *Mem = C.Allocate(Size + sizeof(Stmt *));
+  void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
   OMPTaskgroupDirective *Dir =
   new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc, Clauses.size());
   Dir->setAssociatedStmt(AssociatedStmt);
+  

[PATCH] D34878: [ARM] Option for reading thread pointer from coprocessor register

2017-07-25 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic added a comment.

Hi Bruno,

Yes, GCC has similar option (-mtp=soft/hard), but name is not same. I put the 
same option name as in backend (https://reviews.llvm.org/D34408).


https://reviews.llvm.org/D34878



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


[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-25 Thread Peter Smith via Phabricator via cfe-commits
peter.smith updated this revision to Diff 108092.
peter.smith added a comment.
Herald added a subscriber: javed.absar.

I've added a clang test that will check that none of the floating point helper 
functions defined in the Runtime ABI for the ARM Architecture are directly 
called by clang. Given that the calling convention decisions for these helpers 
are made in llvm I think the best place for a test that the correct calling 
convention is in llvm. I'll start working on that and post in a separate 
review. Please let me know if I'm not on the right lines.


https://reviews.llvm.org/D35538

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/arm-float-helpers.c
  test/CodeGen/complex-math.c

Index: test/CodeGen/complex-math.c
===
--- test/CodeGen/complex-math.c
+++ test/CodeGen/complex-math.c
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
-// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARM
+// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 
 float _Complex add_float_rr(float a, float b) {
@@ -476,8 +477,15 @@
 
 // Check that the libcall will obtain proper calling convention on ARM
 _Complex double foo(_Complex double a, _Complex double b) {
+  // These functions are not defined as floating point helper functions in
+  // Run-time ABI for the ARM architecture document so they must not always
+  // use the base AAPCS
+
   // ARM-LABEL: @foo(
-  // ARM: call arm_aapcscc { double, double } @__muldc3
+  // ARM: call void { double, double } @__muldc3
+
+  // ARMHF-LABEL: @foo(
+  // ARMHF: call { double, double } @__muldc3
 
   // ARM7K-LABEL: @foo(
   // ARM7K: call { double, double } @__muldc3
Index: test/CodeGen/arm-float-helpers.c
===
--- /dev/null
+++ test/CodeGen/arm-float-helpers.c
@@ -0,0 +1,195 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | FileCheck %s
+
+// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The
+// floating-point helper functions to always use the base AAPCS (soft-float)
+// calling convention.
+//
+// These helper functions such as __aeabi_fadd are not explicitly called by
+// clang, instead they are generated by the ARMISelLowering when they are
+// needed; clang relies on llvm to use the base AAPCS.
+//
+// In this test we check that clang is not directly calling the __aeabi_
+// functions. We rely on llvm to test that the base AAPCS is used for any
+// __aeabi_ function from 4.1.2 that is used.
+//
+// When compiled to an object file with -mfloat-abi=soft each function F
+// below should result in a call to __aeabi_F. If clang is changed to call any
+// of these functions directly the test will need to be altered to check that
+// arm_aapcscc is used.
+//
+// Note that it is only the functions in 4.1.2 that must use the base AAPCS,
+// other runtime functions such as the _Complex helper routines are not covered
+
+float fadd(float a, float b) { return a + b; }
+// CHECK: @fadd
+// CHECK-NOT: __aeabi_fadd
+
+float fdiv(float a, float b) { return a / b; }
+// CHECK: @fdiv
+// CHECK-NOT: __aeabi_fdiv
+
+float fmul(float a, float b) { return a * b; }
+// CHECK: @fmul
+// CHECK-NOT: __aeabi_fmul
+
+float fsub(float a, float b) { return a - 

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: include/clang/Basic/Builtins.def:713
+ATOMIC_BUILTIN(__opencl_atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__opencl_atomic_fetch_xor, "v.", "t")
+

b-sumner wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > What about min/max? I believe they will need to have the scope too. 
> > They are not 2.0 atomic builtin functions. They can be implemented as 
> > library functions through 2.0 atomic builtin functions.
> Yes, they are.  Please look again at 6.13.11.7.5 in the 2.0 C spec.
sorry I thought they are just some atomic extensions since C++11 atomic 
builtins do not have those. I will add them.


https://reviews.llvm.org/D28691



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


[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: include/clang/Basic/Builtins.def:713
+ATOMIC_BUILTIN(__opencl_atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__opencl_atomic_fetch_xor, "v.", "t")
+

yaxunl wrote:
> Anastasia wrote:
> > What about min/max? I believe they will need to have the scope too. 
> They are not 2.0 atomic builtin functions. They can be implemented as library 
> functions through 2.0 atomic builtin functions.
Yes, they are.  Please look again at 6.13.11.7.5 in the 2.0 C spec.


https://reviews.llvm.org/D28691



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


[clang-tools-extra] r308975 - [clang-tidy] Fixup clang-apply-replacements/invalid-files test

2017-07-25 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Jul 25 07:39:08 2017
New Revision: 308975

URL: http://llvm.org/viewvc/llvm-project?rev=308975=rev
Log:
[clang-tidy] Fixup clang-apply-replacements/invalid-files test

Modified:
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp

Modified: 
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp?rev=308975=308974=308975=diff
==
--- clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp Tue 
Jul 25 07:39:08 2017
@@ -1,5 +1,6 @@
 // RUN: mkdir -p %T/invalid-files
+// RUN: cp %S/Inputs/invalid-files/invalid-files.yaml 
%T/invalid-files/invalid-files.yaml
 // RUN: clang-apply-replacements %T/invalid-files
 //
 // Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
-// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
+// RUN: ls %T/invalid-files/invalid-files.yaml


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


[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-25 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 108078.
arphaman added a comment.

Simplified the implementation of `LexicallyOrderedRecursiveASTVisitor` and 
removed redundant DenseMap checks.
Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D35012

Files:
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/SourceLocation.h
  include/clang/Basic/SourceManager.h
  include/clang/Tooling/Refactoring/ASTSelection.h
  lib/Tooling/Refactoring/ASTSelection.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/ASTSelectionTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp

Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
===
--- /dev/null
+++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -0,0 +1,141 @@
+//===- unittest/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+class DummyMatchVisitor;
+
+class LexicallyOrderedDeclVisitor
+: public LexicallyOrderedRecursiveASTVisitor {
+public:
+  LexicallyOrderedDeclVisitor(DummyMatchVisitor ,
+  const SourceManager )
+  : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {}
+
+  bool TraverseDecl(Decl *D) {
+TraversalStack.push_back(D);
+LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
+TraversalStack.pop_back();
+return true;
+  }
+
+  bool VisitNamedDecl(const NamedDecl *D);
+
+private:
+  DummyMatchVisitor 
+  llvm::SmallVector TraversalStack;
+};
+
+class DummyMatchVisitor : public ExpectedLocationVisitor {
+public:
+  bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
+const ASTContext  = TU->getASTContext();
+const SourceManager  = Context.getSourceManager();
+LexicallyOrderedDeclVisitor SubVisitor(*this, SM);
+SubVisitor.TraverseDecl(TU);
+return false;
+  }
+
+  void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); }
+};
+
+bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) {
+  std::string Path;
+  llvm::raw_string_ostream OS(Path);
+  assert(TraversalStack.back() == D);
+  for (const Decl *D : TraversalStack) {
+if (isa(D)) {
+  OS << "/";
+  continue;
+}
+if (const auto *ND = dyn_cast(D))
+  OS << ND->getNameAsString();
+else
+  OS << "???";
+if (isa(D))
+  OS << "/";
+  }
+  Matcher.match(OS.str(), D);
+  return true;
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+@implementation I
+
+int nestedFunction() { }
+
+- (void) method{ }
+
+int anotherNestedFunction(int x) {
+  return x;
+}
+
+int innerVariable = 0;
+
+@end
+
+int outerVariable = 0;
+
+@implementation I(Cat)
+
+void catF() { }
+
+@end
+
+void outerFunction() { }
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.DisallowMatch("/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/method/", 8, 1);
+  Visitor.DisallowMatch("/anotherNestedFunction/", 10, 1);
+  Visitor.ExpectMatch("/I/anotherNestedFunction/", 10, 1);
+  Visitor.DisallowMatch("/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/I/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/outerVariable", 18, 1);
+  Visitor.DisallowMatch("/catF/", 22, 1);
+  Visitor.ExpectMatch("/Cat/catF/", 22, 1);
+  Visitor.ExpectMatch("/outerFunction/", 26, 1);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitMacroDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+
+void outerFunction() { }
+
+#define MACRO_F(x) void nestedFunction##x() { }
+
+@implementation I
+
+MACRO_F(1)
+
+@end
+
+MACRO_F(2)
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.ExpectMatch("/outerFunction/", 5, 1);
+  Visitor.ExpectMatch("/I/nestedFunction1/", 7, 20);
+  Visitor.ExpectMatch("/nestedFunction2/", 7, 20);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+} // end anonymous namespace
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -11,11 +11,13 @@
 endif()
 
 add_clang_unittest(ToolingTests
+  ASTSelectionTest.cpp
   CastExprTest.cpp
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
   DiagnosticsYamlTest.cpp
   FixItTest.cpp
+  LexicallyOrderedRecursiveASTVisitorTest.cpp
   

[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via Phabricator via cfe-commits
kfunk added a comment.

Seems to have worked:

  Committing to https://llvm.org/svn/llvm-project/clang-tools-extra/trunk ...
  A   
test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
  A   test/clang-apply-replacements/invalid-files.cpp
  M   clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  Committed r308974

I presume this Diff is being auto-closed by Phab?

Anyhow: Thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D35194



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


[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308974: [clang-tidy] clang-apply-replacements: Don't insert 
null entry (authored by kfunk).

Repository:
  rL LLVM

https://reviews.llvm.org/D35194

Files:
  
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
  clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp


Index: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement  : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 
@@ -314,13 +313,12 @@
 for (const tooling::Replacement  : Fix.second) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 }
Index: clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
===
--- clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
+++ clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/invalid-files
+// RUN: clang-apply-replacements %T/invalid-files
+//
+// Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
+// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
Index: 
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===
--- 
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
+++ 
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+...


Index: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement  : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
   

[clang-tools-extra] r308974 - [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Jul 25 07:28:16 2017
New Revision: 308974

URL: http://llvm.org/viewvc/llvm-project?rev=308974=rev
Log:
[clang-tidy] clang-apply-replacements: Don't insert null entry

Summary:
[clang-tidy] clang-apply-replacements: Don't insert null entry

Fix crash when running clang-apply-replacements on YML files which
contain an invalid file path. Make sure we never add a nullptr into the
map. The previous code started adding nullptr to the map after the first
warnings via errs() has been emitted.

Backtrace:
```
Starting program:
/home/kfunk/devel/build/llvm/bin/clang-apply-replacements /tmp/tmpIqtp7m
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/x86_64-linux-gnu/libthread_db.so.1".
Described file 
'.moc/../../../../../../src/qt5.8/qtremoteobjects/src/remoteobjects/qremoteobjectregistrysource_p.h'
 doesn't exist. Ignoring...
...

Program received signal SIGSEGV, Segmentation fault.
main (argc=, argv=) at 
/home/kfunk/devel/src/llvm/tools/clang/tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:262
(gdb) p FileAndReplacements.first
$1 = (const clang::FileEntry *) 0x0
(gdb)
```

Added tests.

Before patch:

```
 TEST 'Clang Tools :: 
clang-apply-replacements/invalid-files.cpp' FAILED 
Script:
--
mkdir -p 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
clang-apply-replacements 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
ls -1 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
 | FileCheck 
/home/kfunk/devel/src/llvm/tools/clang/tools/extra/test/clang-apply-replacements/invalid-files.cpp
 --check-prefix=YAML
--
Exit Code: 139

Command Output (stderr):
--
Described file 'idonotexist.h' doesn't exist. Ignoring...
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/invalid-files.cpp.script:
 line 4:  9919 Segmentation fault  clang-apply-replacements 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-   
replacements/Output/Inputs/invalid-files

--
```

After Patch:

```
PASS: Clang Tools :: clang-apply-replacements/invalid-files.cpp (5 of 6)
```

Reviewers: alexfh, yawanng

Reviewed By: alexfh

Subscribers: cfe-commits, klimek, JDevlieghere, xazax.hun

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
Modified:

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=308974=308973=308974=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 Tue Jul 25 07:28:16 2017
@@ -288,13 +288,12 @@ bool mergeAndDeduplicate(const TUReplace
 for (const tooling::Replacement  : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 
@@ -314,13 +313,12 @@ bool mergeAndDeduplicate(const TUDiagnos
 for (const tooling::Replacement  : Fix.second) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } 

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 108073.
yaxunl marked 16 inline comments as done.
yaxunl edited the summary of this revision.
yaxunl added a reviewer: kzhuravl.
yaxunl added a comment.
Herald added a subscriber: nhaehnle.

Rebased to ToT and revised by Anastasia's comments.


https://reviews.llvm.org/D28691

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/StmtPrinter.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- /dev/null
+++ test/SemaOpenCL/atomic-ops.cl
@@ -0,0 +1,151 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+
+// Basic parsing/Sema tests for __opencl_atomic_*
+
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+
+struct S { char c[3]; };
+
+char i8;
+short i16;
+int i32;
+int8 i64;
+
+atomic_int gn;
+
+void f(atomic_int *i, const atomic_int *ci,
+   atomic_intptr_t *p, atomic_float *d,
+   int *I, const int *CI,
+   intptr_t *P, float *D, struct S *s1, struct S *s2,
+   global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
+   constant atomic_int *i_c) {
+  __opencl_atomic_init(I, 5); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __opencl_atomic_load(0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 3, have 4}}
+  __opencl_atomic_store(0,0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
+  __opencl_atomic_store((int *)0, 0, 0, 0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic type ('__generic int *' invalid)}}
+  __opencl_atomic_store(i, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(ci, 0, memory_order_relaxed, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+  __opencl_atomic_store(i_g, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_l, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_p, 0, memory_order_relaxed, memory_scope_work_item);
+  __opencl_atomic_store(i_c, 0, memory_order_relaxed, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
+
+  __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+
+  int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
+
+  __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_item);
+  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_item); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka 

[PATCH] D28691: Add OpenCL 2.0 atomic builtin functions as Clang builtin

2017-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 16 inline comments as done.
yaxunl added inline comments.



Comment at: include/clang/Basic/Builtins.def:713
+ATOMIC_BUILTIN(__opencl_atomic_fetch_or, "v.", "t")
+ATOMIC_BUILTIN(__opencl_atomic_fetch_xor, "v.", "t")
+

Anastasia wrote:
> What about min/max? I believe they will need to have the scope too. 
They are not 2.0 atomic builtin functions. They can be implemented as library 
functions through 2.0 atomic builtin functions.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6956
+  "synchronization scope argument to atomic operation is invalid">;
+def err_atomic_op_has_non_constant_synch_scope : Error<
+  "non-constant synchronization scope argument to atomic operation is not 
supported">;

Anastasia wrote:
> Btw, is this disallowed by the spec? Can't find anything relevant.
Just temporarily not supported by Clang. Will add support later.



Comment at: lib/CodeGen/CGAtomic.cpp:678
 RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
+  bool IsOpenCL = E->isOpenCL();
   QualType AtomicTy = E->getPtr()->getType()->getPointeeType();

Anastasia wrote:
> Seems short enough to introduce an extra variable here. :)
removed the variable



Comment at: lib/CodeGen/CGAtomic.cpp:707
 
-  switch (E->getOp()) {
+  auto Op = E->getOp();
+  switch (Op) {

Anastasia wrote:
> The same here... not sure adding an extra variable is helping here. :)
removed the variable



Comment at: lib/CodeGen/CGAtomic.cpp:889
+return V;
+  auto OrigLangAS = E->getType()
+.getTypePtr()

Anastasia wrote:
> Formatting seems to be a bit odd here...
this is done by clang-format



Comment at: lib/CodeGen/CGAtomic.cpp:1117
+  "Non-constant synchronization scope not supported");
+  auto sco = (llvm::SynchronizationScope)(
+  cast(Scope)->getZExtValue());

Anastasia wrote:
> Anastasia wrote:
> > Variable name doesn't follow the style.
> could we avoid using C style cast?
will fix



Comment at: lib/CodeGen/CGAtomic.cpp:1117
+  "Non-constant synchronization scope not supported");
+  auto sco = (llvm::SynchronizationScope)(
+  cast(Scope)->getZExtValue());

yaxunl wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > Variable name doesn't follow the style.
> > could we avoid using C style cast?
> will fix
will change to static_cast



Comment at: lib/Sema/SemaChecking.cpp:3146
+Op == AtomicExpr::AO__opencl_atomic_load)
+? 0
+: 1);

Anastasia wrote:
> formatting seems odd.
this is done by clang-format



Comment at: test/CodeGenOpenCL/atomic-ops-libcall.cl:1
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple spir64 
-emit-llvm | FileCheck -check-prefix=GEN4 %s
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple 
armv5e-none-linux-gnueabi -emit-llvm | FileCheck -check-prefix=GEN0 %s

Anastasia wrote:
> GEN4 -> SPIR
will change



Comment at: test/CodeGenOpenCL/atomic-ops-libcall.cl:2
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple spir64 
-emit-llvm | FileCheck -check-prefix=GEN4 %s
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple 
armv5e-none-linux-gnueabi -emit-llvm | FileCheck -check-prefix=GEN0 %s
+

Anastasia wrote:
> GEN0 -> AMDGPU
Actually this triple is armv5e. This test requires a target not supporting 
atomic instructions. Will change GEN0 -> ARM



Comment at: test/CodeGenOpenCL/atomic-ops-libcall.cl:4
+
+void f(atomic_int *i, int cmp) {
+  int x;

Anastasia wrote:
> Could we use different scopes?
Yes. will add them.



Comment at: test/CodeGenOpenCL/atomic-ops.cl:7
+
+#ifndef ALREADY_INCLUDED
+#define ALREADY_INCLUDED

Anastasia wrote:
> why do we need this?
This is to test the builtin works in pch. When generating pch, ALREADY_INCLUDED 
is undefined, therefore pch will include all functions. When including pch, 
since ALREADY_INCLUDED is defined through pch, the cl file is empty and 
function definitions from pch is used for codegen.



Comment at: test/CodeGenOpenCL/atomic-ops.cl:15
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{[.0-9A-Z_a-z]+}} 
singlethread seq_cst
+  int x = __opencl_atomic_load(i, memory_order_seq_cst, 
memory_scope_work_item);
+}

Anastasia wrote:
> I think we could use different scope types all over...
will add them.



Comment at: test/CodeGenOpenCL/atomic-ops.cl:32
+  // CHECK-LABEL: @fi4(
+  // CHECK: [[PAIR:%[.0-9A-Z_a-z]+]] = cmpxchg i32 addrspace(4)* 
[[PTR:%[.0-9A-Z_a-z]+]], i32 [[EXPECTED:%[.0-9A-Z_a-z]+]], i32 
[[DESIRED:%[.0-9A-Z_a-z]+]] singlethread acquire 

[PATCH] D35624: Removal of microMIPS64R6

2017-07-25 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji updated this revision to Diff 108067.
abeserminji added a comment.

Comments resolved and patch adapted to current revision.


Repository:
  rL LLVM

https://reviews.llvm.org/D35624

Files:
  Basic/Targets/Mips.cpp
  clang/Basic/DiagnosticCommonKinds.td


Index: Basic/Targets/Mips.cpp
===
--- Basic/Targets/Mips.cpp
+++ Basic/Targets/Mips.cpp
@@ -203,6 +203,12 @@
 }
 
 bool MipsTargetInfo::validateTarget(DiagnosticsEngine ) const {
+  if ((getTriple().getArch() == llvm::Triple::mips64 ||
+   getTriple().getArch() == llvm::Triple::mips64el) &&
+   IsMicromips && (ABI == "n32" || ABI == "n64")) {
+Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
+return false;
+  }
   // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
   //this yet. It's better to fail here than on the backend assertion.
   if (processorSupportsGPR64() && ABI == "o32") {
Index: clang/Basic/DiagnosticCommonKinds.td
===
--- clang/Basic/DiagnosticCommonKinds.td
+++ clang/Basic/DiagnosticCommonKinds.td
@@ -185,6 +185,8 @@
 def err_target_unknown_triple : Error<
   "unknown target triple '%0', please use -triple or -arch">;
 def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
+def err_target_unsupported_cpu_for_micromips : Error<
+  "micromips is not supported for target CPU '%0'">;
 def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
 def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU 
'%1'">;
 def err_target_unsupported_abi_for_triple : Error<


Index: Basic/Targets/Mips.cpp
===
--- Basic/Targets/Mips.cpp
+++ Basic/Targets/Mips.cpp
@@ -203,6 +203,12 @@
 }
 
 bool MipsTargetInfo::validateTarget(DiagnosticsEngine ) const {
+  if ((getTriple().getArch() == llvm::Triple::mips64 ||
+   getTriple().getArch() == llvm::Triple::mips64el) &&
+   IsMicromips && (ABI == "n32" || ABI == "n64")) {
+Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
+return false;
+  }
   // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
   //this yet. It's better to fail here than on the backend assertion.
   if (processorSupportsGPR64() && ABI == "o32") {
Index: clang/Basic/DiagnosticCommonKinds.td
===
--- clang/Basic/DiagnosticCommonKinds.td
+++ clang/Basic/DiagnosticCommonKinds.td
@@ -185,6 +185,8 @@
 def err_target_unknown_triple : Error<
   "unknown target triple '%0', please use -triple or -arch">;
 def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
+def err_target_unsupported_cpu_for_micromips : Error<
+  "micromips is not supported for target CPU '%0'">;
 def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
 def err_target_unsupported_abi : Error<"ABI '%0' is not supported on CPU '%1'">;
 def err_target_unsupported_abi_for_triple : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35624: Removal of microMIPS64R6

2017-07-25 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji marked 2 inline comments as done.
abeserminji added a comment.

Comments resolved


Repository:
  rL LLVM

https://reviews.llvm.org/D35624



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


[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

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

LG. Do you need someone to commit the patch for you?


https://reviews.llvm.org/D35194



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


[PATCH] D35624: Removal of microMIPS64R6

2017-07-25 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a reviewer: cfe-commits.
sdardis added a comment.

Also, this need to be posted to cfe-commits.


Repository:
  rL LLVM

https://reviews.llvm.org/D35624



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


[PATCH] D33672: [analyzer] INT50-CPP. Do not cast to an out-of-range enumeration checker

2017-07-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33672#819683, @xazax.hun wrote:

> Aaron, could you comment on the applicability of this check to C? Thanks in 
> advance.


C has different rules for their enumerations in that the enumerators are all 
ints, but the enumeration type is either `char`, a signed integer type, or an 
unsigned integer type depending on the values of the enumerators. So this 
problem exists:

  enum E {
one = 1
  };
  
  void f(int i) {
enum E e = (enum E)i;
  }
  
  int main(void) {
f(1024);
  }

If `enum E` is represented by a `char`, then the cast causes a loss of 
precision. However, this isn't undefined behavior in C like it is in C++.




Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:29
+namespace {
+// This evaluator checks 2 SVals for equality. The first SVal is provided via
+// the constructor, the second is the parameter of the overloaded () operator.

s/2/two



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:34
+class ConstraintBasedEQEvaluator {
+private:
+  const DefinedOrUnknownSVal CompareValue;

No need for the access specifier; it defaults to `private`.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:47
+DefinedOrUnknownSVal EnumDeclValue = SVB.makeIntVal(EnumDeclInitValue);
+const auto ElemEqualsValueToCast =
+SVB.evalEQ(PS, EnumDeclValue, CompareValue);

Please do not use `auto` here as the type is not spelled out in the 
initialization. Also, you can drop the `const` qualifier if it's not a pointer 
or reference type.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:74-75
+  EnumValueVector DeclValues;
+  for (const auto *D : ED->decls()) {
+const auto ECD = dyn_cast(D);
+DeclValues.push_back(ECD->getInitVal());

Instead of enumerating over `decls()` and then casting, just enumerate over 
`enumerators()` and  the cast isn't needed. Or, even better:
```
EnumValueVector DeclValues(ED->enumerator_end() - ED->enumerator_begin());
std::transform(ED->enumerator_begin(), ED->enumerator_end(), DeclValues.begin(),
   [](const EnumConstantDecl *D) { return D->getInitVal(); 
});
```



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:84
+void EnumCastOutOfRangeChecker::reportWarning(CheckerContext ) const {
+  if (auto N = C.generateNonFatalErrorNode(C.getState())) {
+if (!EnumValueCastOutOfRange)

NoQ wrote:
> `C.getState()` is the default value (if you see how 
> `generateNonFatalErrorNode()` calls `addTransition()` which in turns 
> substitutes nullptr with `getState()`), so it can be omitted.
Don't use `auto` here.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:87-89
+  new BuiltinBug(this, "Enum cast out of range",
+ "The value provided to the cast expression is not in "
+ "the valid range of values for the enum."));

Also, diagnostics should not be full sentences or grammatically correct, so 
drop the capitalization and full stop.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:116
+  // function to handle this.
+  const EnumDecl *ED = T->getAs()->getDecl();
+

You can use `castAs<>()` because you've already determined it's an enumeral 
type.



Comment at: lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:121
+  bool PossibleValueMatch =
+  std::any_of(DeclValues.begin(), DeclValues.end(),
+  ConstraintBasedEQEvaluator(C, *ValueToCastOptional));

You can use `llvm::any_of()` and pass in the container.


https://reviews.llvm.org/D33672



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


[PATCH] D35194: [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via Phabricator via cfe-commits
kfunk updated this revision to Diff 108061.
kfunk added a comment.

Addressed concerns


https://reviews.llvm.org/D35194

Files:
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
  test/clang-apply-replacements/invalid-files.cpp


Index: test/clang-apply-replacements/invalid-files.cpp
===
--- /dev/null
+++ test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/invalid-files
+// RUN: clang-apply-replacements %T/invalid-files
+//
+// Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
+// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
Index: test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===
--- /dev/null
+++ test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+...
Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement  : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 
@@ -314,13 +313,12 @@
 for (const tooling::Replacement  : Fix.second) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 }


Index: test/clang-apply-replacements/invalid-files.cpp
===
--- /dev/null
+++ test/clang-apply-replacements/invalid-files.cpp
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %T/invalid-files
+// RUN: clang-apply-replacements %T/invalid-files
+//
+// Check that the yaml files are *not* deleted after running clang-apply-replacements without remove-change-desc-files.
+// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
Index: test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
===
--- /dev/null
+++ test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
@@ -0,0 +1,12 @@
+---
+MainSourceFile:  ''
+Replacements:
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+  - FilePath:idontexist.h
+Offset:  2669
+Length:  0
+ReplacementText: ' override'
+...
Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -288,13 +288,12 @@
 for (const tooling::Replacement  : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << 

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D32210#819577, @ahatanak wrote:

> In https://reviews.llvm.org/D32210#810508, @rjmccall wrote:
>
> > Hmm.  Unfortunately, I'm not sure that's valid.  The retains and releases 
> > of block captures don't protect against anything related to escaping the 
> > block; they protect against the original variables being modified during 
> > the lifetime of the block.  It is true that a block literal passed to a 
> > noescape parameter has a shorter effective lifetime — we know for certain 
> > that it will be unused after the call, and ARC only promises that a value 
> > in an imprecise-lifetime strong variable like a block capture will be valid 
> > until the last load of that value from the variable.  But that duration is 
> > still long enough for someone to modify the original variable in a way that 
> > is properly sequenced after the formation of the block.
> >
> > Now, if you could prove that the variable was not modified for the duration 
> > of the call, that would be sufficient.  And that would be easy to do in the 
> > common case by just proving that the address of the variable never escapes. 
> >  Unfortunately, we don't have that information readily available because 
> > Sema doesn't collect it.
>
>
> OK, so I guess the optimization isn't valid in the following case, for 
> example:
>
>   void foo3(id);
>  
>   id __strong *gp;
>  
>   void foo2(id a) {
> gp = 
> nonescapingFunc(^{ foo3(a); }); // this function can modify "a" before 
> the block is executed.
>   }
>


Right.

>> There are some other ways you could optimize blocks that are known not to 
>> escape, though.  One big caveat is that you have to make sure the block 
>> behaves reasonably in response to being copied, becase being noescape 
>> doesn't guarantee that the callee won't try to copy the block.  However:
> 
> I didn't understand the following optimizations. I thought clang doesn't emit 
> copy and destroy helper for global blocks with or without noescape?

They're not really about global blocks, they're about whether we can emit a 
non-escaping block using the isa that we use for global blocks, which causes 
copies to be no-ops (because real global blocks do not have local captures).

John.




Comment at: include/clang/AST/Type.h:3156
 };
 unsigned char Data;
 

ahatanak wrote:
> rjmccall wrote:
> > Oh!  I hadn't noticed that you were adding this to ExtParameterInfo.  
> > You're modifying the function type system; there's a lot of complexity to 
> > do that properly which you haven't done in this patch at all.  That's 
> > especially true because, unlike all these other ExtParameterInfo cases, 
> > there's a natural subtyping rule for escaping parameters: a function type 
> > that takes a non-escaping parameter should be implicitly convertible to be 
> > a function type that takes an escaping parameter.  You will also need to 
> > update a bunch of things, including the type printer, the mangler, the C++ 
> > function conversion rules, the C type compatibility rules, the 
> > redeclaration type matcher, and maybe even template argument deduction.  
> > It's a big thing to do.
> > 
> > You will want Sema tests in C, ObjC, C++, and ObjC++.
> Rather than adding an enum to ExtParameterInfo and modifying the type system, 
> I made changes in IRGen to find out whether a function parameter is annotated 
> with noescape. I'm not sure when it is OK or not OK to change the type system 
> when adding support for an attribute, but this seemed to be the right 
> direction since most of the other attributes are handled this way.
So, I do think it's acceptable to change the type system here; it's just that 
doing so definitely makes the change more complicated.

The guidance here is:
  - If it changes the basic rules for making a call, it really *must* be 
preserved as part of the function type, or else basic things like taking the 
address of the function will never work correctly.  That's why everything 
currently in ExtParameterInfo is there — ns_consumed affects the balancing 
rules for how ARC makes calls, the Swift parameter-ABI treatments are part of 
the CC, etc.
  - Otherwise, it really comes down to how much we care about the feature 
working with indirection.  I feel like blocks are probably the strongest 
motivator here because they're always invoked indirectly: if you want the 
feature to work on a block parameter, it really needs to be part of the 
function type, because we do not want to get into the business of finding 
non-canonical sources of information for function types, e.g. param decls from 
the TypeSourceInfo.

Overall, I would say that it tends to be the case that we eventually find 
attribute-based analyses limiting.  If we start doing serious optimizations 
based on noescape, it is probably something that ought to go in the type system.



Comment at: lib/CodeGen/CGCall.cpp:2096
+if 

[PATCH] D35796: [analyzer] Misused polymorphic object checker

2017-07-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

It seems that this check is more powerful because it works by knowing the 
dynamic type of the object. However, i still suspect that `-Wnon-virtual-dtor` 
(the other one, without `delete-`, that simply asks to make the destructor of 
polymorphic classes virtual) covers most practical cases. The only thing i see 
not covered by `-Wnon-virtual-dtor` but covered by this checker is the 
situation when the destructor is private. Reka, would you confirm our 
understanding?


https://reviews.llvm.org/D35796



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


  1   2   >