Re: [PATCH] D15674: [CodeGen] Fix assignments of inline layouts into the byref structure

2015-12-21 Thread Vedant Kumar via cfe-commits
vsk updated this revision to Diff 43384.
vsk added a comment.

- Update patch according to John's comments.


http://reviews.llvm.org/D15674

Files:
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CGObjCRuntime.h
  test/CodeGenObjCXX/blocks.mm

Index: test/CodeGenObjCXX/blocks.mm
===
--- test/CodeGenObjCXX/blocks.mm
+++ test/CodeGenObjCXX/blocks.mm
@@ -68,3 +68,18 @@
 takeBlock(^{ useValues(ptr, this); });
   }
 };
+
+// rdar://problem/23713871
+// Check that we don't crash when using BLOCK_LAYOUT_STRONG.
+#pragma clang assume_nonnull begin
+@interface NSUUID @end
+#pragma clang assume_nonnull end
+
+struct Wrapper1 { NSUUID *Ref; };
+struct Wrapper2 { Wrapper1 W1; };
+
+@implementation B
+- (void) captureStrongRef {
+  __block Wrapper2 W2;
+}
+@end
Index: lib/CodeGen/CGObjCRuntime.h
===
--- lib/CodeGen/CGObjCRuntime.h
+++ lib/CodeGen/CGObjCRuntime.h
@@ -275,8 +275,11 @@
   const CodeGen::CGBlockInfo ) = 0;
   virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule ,
   const CodeGen::CGBlockInfo ) = 0;
+
+  /// Returns an i8* which points to the byref layout information.
   virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule ,
QualType T) = 0;
+
   virtual llvm::GlobalVariable *GetClassGlobal(const std::string ,
bool Weak = false) = 0;
 
Index: lib/CodeGen/CGObjCMac.cpp
===
--- lib/CodeGen/CGObjCMac.cpp
+++ lib/CodeGen/CGObjCMac.cpp
@@ -2517,7 +2517,8 @@
 printf(", BL_WEAK:%d", (int) numWeak);
   printf(", BL_OPERATOR:0\n");
 }
-return llvm::ConstantInt::get(CGM.IntPtrTy, Result);
+return llvm::ConstantExpr::getIntToPtr(
+llvm::ConstantInt::get(CGM.IntPtrTy, Result), CGM.Int8PtrTy);
   }
   
   unsigned char inst = (BLOCK_LAYOUT_OPERATOR << 4) | 0;


Index: test/CodeGenObjCXX/blocks.mm
===
--- test/CodeGenObjCXX/blocks.mm
+++ test/CodeGenObjCXX/blocks.mm
@@ -68,3 +68,18 @@
 takeBlock(^{ useValues(ptr, this); });
   }
 };
+
+// rdar://problem/23713871
+// Check that we don't crash when using BLOCK_LAYOUT_STRONG.
+#pragma clang assume_nonnull begin
+@interface NSUUID @end
+#pragma clang assume_nonnull end
+
+struct Wrapper1 { NSUUID *Ref; };
+struct Wrapper2 { Wrapper1 W1; };
+
+@implementation B
+- (void) captureStrongRef {
+  __block Wrapper2 W2;
+}
+@end
Index: lib/CodeGen/CGObjCRuntime.h
===
--- lib/CodeGen/CGObjCRuntime.h
+++ lib/CodeGen/CGObjCRuntime.h
@@ -275,8 +275,11 @@
   const CodeGen::CGBlockInfo ) = 0;
   virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule ,
   const CodeGen::CGBlockInfo ) = 0;
+
+  /// Returns an i8* which points to the byref layout information.
   virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule ,
QualType T) = 0;
+
   virtual llvm::GlobalVariable *GetClassGlobal(const std::string ,
bool Weak = false) = 0;
 
Index: lib/CodeGen/CGObjCMac.cpp
===
--- lib/CodeGen/CGObjCMac.cpp
+++ lib/CodeGen/CGObjCMac.cpp
@@ -2517,7 +2517,8 @@
 printf(", BL_WEAK:%d", (int) numWeak);
   printf(", BL_OPERATOR:0\n");
 }
-return llvm::ConstantInt::get(CGM.IntPtrTy, Result);
+return llvm::ConstantExpr::getIntToPtr(
+llvm::ConstantInt::get(CGM.IntPtrTy, Result), CGM.Int8PtrTy);
   }
   
   unsigned char inst = (BLOCK_LAYOUT_OPERATOR << 4) | 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15674: [CodeGen] Fix assignments of inline layouts into the byref structure

2015-12-21 Thread John McCall via cfe-commits
rjmccall added a comment.

Thank you, that's great.  LGTM.


http://reviews.llvm.org/D15674



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


r256186 - Revert "[CodeGen] Fix assignments of inline layouts into the byref structure"

2015-12-21 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Dec 21 13:43:25 2015
New Revision: 256186

URL: http://llvm.org/viewvc/llvm-project?rev=256186=rev
Log:
Revert "[CodeGen] Fix assignments of inline layouts into the byref structure"

This reverts commit r256185. It breaks CodeGenObjC/fragile-arc.m.

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
cfe/trunk/test/CodeGenObjCXX/blocks.mm

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=256186=256185=256186=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Dec 21 13:43:25 2015
@@ -2517,8 +2517,7 @@ llvm::Constant *CGObjCCommonMac::getBitm
 printf(", BL_WEAK:%d", (int) numWeak);
   printf(", BL_OPERATOR:0\n");
 }
-return llvm::ConstantExpr::getIntToPtr(
-llvm::ConstantInt::get(CGM.IntPtrTy, Result), CGM.Int8PtrTy);
+return llvm::ConstantInt::get(CGM.IntPtrTy, Result);
   }
   
   unsigned char inst = (BLOCK_LAYOUT_OPERATOR << 4) | 0;

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=256186=256185=256186=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Mon Dec 21 13:43:25 2015
@@ -275,11 +275,8 @@ public:
   const CodeGen::CGBlockInfo ) = 0;
   virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule ,
   const CodeGen::CGBlockInfo ) = 0;
-
-  /// Returns an i8* which points to the byref layout information.
   virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule ,
QualType T) = 0;
-
   virtual llvm::GlobalVariable *GetClassGlobal(const std::string ,
bool Weak = false) = 0;
 

Modified: cfe/trunk/test/CodeGenObjCXX/blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/blocks.mm?rev=256186=256185=256186=diff
==
--- cfe/trunk/test/CodeGenObjCXX/blocks.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/blocks.mm Mon Dec 21 13:43:25 2015
@@ -68,18 +68,3 @@ class CaptureThisAndAnotherPointer {
 takeBlock(^{ useValues(ptr, this); });
   }
 };
-
-// rdar://problem/23713871
-// Check that we don't crash when using BLOCK_LAYOUT_STRONG.
-#pragma clang assume_nonnull begin
-@interface NSUUID @end
-#pragma clang assume_nonnull end
-
-struct Wrapper1 { NSUUID *Ref; };
-struct Wrapper2 { Wrapper1 W1; };
-
-@implementation B
-- (void) captureStrongRef {
-  __block Wrapper2 W2;
-}
-@end


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


Re: [PATCH] D15674: [CodeGen] Fix assignments of inline layouts into the byref structure

2015-12-21 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Thanks for the review. Committed r256185


http://reviews.llvm.org/D15674



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


r256175 - clang-format: Properly set the BlockKind for more blocks.

2015-12-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 21 12:31:15 2015
New Revision: 256175

URL: http://llvm.org/viewvc/llvm-project?rev=256175=rev
Log:
clang-format: Properly set the BlockKind for more blocks.

Before:
  void f() { struct Dummy { };
f();
  }

After:
  void f() {
struct Dummy {};
f();
  }

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=256175=256174=256175=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Dec 21 12:31:15 2015
@@ -321,7 +321,7 @@ void UnwrappedLineParser::calculateBrace
   SmallVector LBraceStack;
   assert(Tok->Tok.is(tok::l_brace));
   do {
-// Get next none-comment token.
+// Get next non-comment token.
 FormatToken *NextTok;
 unsigned ReadTokens = 0;
 do {
@@ -403,6 +403,7 @@ void UnwrappedLineParser::parseBlock(boo
   assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
  "'{' or macro block token expected");
   const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin);
+  FormatTok->BlockKind = BK_Block;
 
   unsigned InitialLevel = Line->Level;
   nextToken();
@@ -421,6 +422,7 @@ void UnwrappedLineParser::parseBlock(boo
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;
+FormatTok->BlockKind = BK_Block;
 return;
   }
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256175=256174=256175=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 21 12:31:15 2015
@@ -313,7 +313,7 @@ TEST_F(FormatTest, FormatIfWithoutCompou
"  f();\n"
"}",
AllowsMergedIf);
-  verifyFormat("if (a) {/* Never merge this */\n"
+  verifyFormat("if (a) { /* Never merge this */\n"
"  f();\n"
"}",
AllowsMergedIf);
@@ -6532,6 +6532,12 @@ TEST_F(FormatTest, FormatsBracedListsInC
"   b};");
 
   verifyNoCrash("a<,");
+  
+  // No braced initializer here.
+  verifyFormat("void f() {\n"
+   "  struct Dummy {};\n"
+   "  f(v);\n"
+   "}");
 }
 
 TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {


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


r256190 - Reapply "[CodeGen] Fix assignments of inline layouts into the byref structure"

2015-12-21 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Dec 21 14:21:15 2015
New Revision: 256190

URL: http://llvm.org/viewvc/llvm-project?rev=256190=rev
Log:
Reapply "[CodeGen] Fix assignments of inline layouts into the byref structure"

When using blocks, a byref structure is created to represent the
closure. The "byref.layout" field of this structure is an i8*. However,
some 'inline' layouts are represented as i64's, not i8*'s.

Prior to r246985 we cast the i64 'inline' layout to an i8* before
assigning it into the byref structure. This patch brings the cast back
and adds a regression test.

The original version of this patch was too invasive. This version only adds the
cast to BuildByrefLayout.

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

rdar://23713871

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
cfe/trunk/test/CodeGenObjCXX/blocks.mm

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=256190=256189=256190=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Dec 21 14:21:15 2015
@@ -2640,6 +2640,8 @@ llvm::Constant *CGObjCCommonMac::BuildBy
   if (const RecordType *record = T->getAs()) {
 BuildRCBlockVarRecordLayout(record, fieldOffset, hasUnion, true 
/*ByrefLayout */);
 llvm::Constant *Result = getBitmapBlockLayout(true);
+if (isa(Result))
+  Result = llvm::ConstantExpr::getIntToPtr(Result, CGM.Int8PtrTy);
 return Result;
   }
   llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy);

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=256190=256189=256190=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Mon Dec 21 14:21:15 2015
@@ -275,8 +275,11 @@ public:
   const CodeGen::CGBlockInfo ) = 0;
   virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule ,
   const CodeGen::CGBlockInfo ) = 0;
+
+  /// Returns an i8* which points to the byref layout information.
   virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule ,
QualType T) = 0;
+
   virtual llvm::GlobalVariable *GetClassGlobal(const std::string ,
bool Weak = false) = 0;
 

Modified: cfe/trunk/test/CodeGenObjCXX/blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/blocks.mm?rev=256190=256189=256190=diff
==
--- cfe/trunk/test/CodeGenObjCXX/blocks.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/blocks.mm Mon Dec 21 14:21:15 2015
@@ -68,3 +68,18 @@ class CaptureThisAndAnotherPointer {
 takeBlock(^{ useValues(ptr, this); });
   }
 };
+
+// rdar://problem/23713871
+// Check that we don't crash when using BLOCK_LAYOUT_STRONG.
+#pragma clang assume_nonnull begin
+@interface NSUUID @end
+#pragma clang assume_nonnull end
+
+struct Wrapper1 { NSUUID *Ref; };
+struct Wrapper2 { Wrapper1 W1; };
+
+@implementation B
+- (void) captureStrongRef {
+  __block Wrapper2 W2;
+}
+@end


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


r256185 - [CodeGen] Fix assignments of inline layouts into the byref structure

2015-12-21 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Dec 21 13:30:37 2015
New Revision: 256185

URL: http://llvm.org/viewvc/llvm-project?rev=256185=rev
Log:
[CodeGen] Fix assignments of inline layouts into the byref structure

When using blocks, a byref structure is created to represent the
closure. The "byref.layout" field of this structure is an i8*. However,
some 'inline' layouts are represented as i64's, not i8*'s.

Prior to r246985 we cast the i64 'inline' layout to an i8* before
assigning it into the byref structure. This patch brings the cast back
and adds a regression test.

rdar://23713871

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
cfe/trunk/test/CodeGenObjCXX/blocks.mm

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=256185=256184=256185=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Dec 21 13:30:37 2015
@@ -2517,7 +2517,8 @@ llvm::Constant *CGObjCCommonMac::getBitm
 printf(", BL_WEAK:%d", (int) numWeak);
   printf(", BL_OPERATOR:0\n");
 }
-return llvm::ConstantInt::get(CGM.IntPtrTy, Result);
+return llvm::ConstantExpr::getIntToPtr(
+llvm::ConstantInt::get(CGM.IntPtrTy, Result), CGM.Int8PtrTy);
   }
   
   unsigned char inst = (BLOCK_LAYOUT_OPERATOR << 4) | 0;

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=256185=256184=256185=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Mon Dec 21 13:30:37 2015
@@ -275,8 +275,11 @@ public:
   const CodeGen::CGBlockInfo ) = 0;
   virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule ,
   const CodeGen::CGBlockInfo ) = 0;
+
+  /// Returns an i8* which points to the byref layout information.
   virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule ,
QualType T) = 0;
+
   virtual llvm::GlobalVariable *GetClassGlobal(const std::string ,
bool Weak = false) = 0;
 

Modified: cfe/trunk/test/CodeGenObjCXX/blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/blocks.mm?rev=256185=256184=256185=diff
==
--- cfe/trunk/test/CodeGenObjCXX/blocks.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/blocks.mm Mon Dec 21 13:30:37 2015
@@ -68,3 +68,18 @@ class CaptureThisAndAnotherPointer {
 takeBlock(^{ useValues(ptr, this); });
   }
 };
+
+// rdar://problem/23713871
+// Check that we don't crash when using BLOCK_LAYOUT_STRONG.
+#pragma clang assume_nonnull begin
+@interface NSUUID @end
+#pragma clang assume_nonnull end
+
+struct Wrapper1 { NSUUID *Ref; };
+struct Wrapper2 { Wrapper1 W1; };
+
+@implementation B
+- (void) captureStrongRef {
+  __block Wrapper2 W2;
+}
+@end


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


r256191 - Tweak myriad-toolchain test.

2015-12-21 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Mon Dec 21 14:30:49 2015
New Revision: 256191

URL: http://llvm.org/viewvc/llvm-project?rev=256191=rev
Log:
Tweak myriad-toolchain test.

The test failed when run on a SPARC host, since it was finding the
native gcc installation by accident.

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

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=256191=256190=256191=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Mon Dec 21 14:30:49 2015
@@ -1,5 +1,5 @@
 // RUN: %clang -no-canonical-prefixes -### -target sparc-myriad-rtems-elf %s \
-// RUN: -B %S/Inputs/basic_myriad_tree 2>&1 | FileCheck %s 
-check-prefix=LINK_WITH_RTEMS
+// RUN: --gcc-toolchain=%S/Inputs/basic_myriad_tree 2>&1 | FileCheck %s 
-check-prefix=LINK_WITH_RTEMS
 // LINK_WITH_RTEMS: Inputs{{.*}}crti.o
 // LINK_WITH_RTEMS: Inputs{{.*}}crtbegin.o
 // LINK_WITH_RTEMS: 
"-L{{.*}}Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../..{{/|}}../sparc-myriad-elf/lib"
@@ -9,7 +9,7 @@
 // LINK_WITH_RTEMS: Inputs{{.*}}crtn.o
 
 // RUN: %clang -c -no-canonical-prefixes -### -target sparc-myriad-rtems-elf 
-x c++ %s \
-// RUN: -B %S/Inputs/basic_myriad_tree 2>&1 | FileCheck %s 
-check-prefix=COMPILE_CXX
+// RUN: --gcc-toolchain=%S/Inputs/basic_myriad_tree 2>&1 | FileCheck %s 
-check-prefix=COMPILE_CXX
 // COMPILE_CXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../../../sparc-myriad-elf/include/c++/4.8.2"
 // COMPILE_CXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../../../sparc-myriad-elf/include/c++/4.8.2/sparc-myriad-elf"
 // COMPILE_CXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../../../sparc-myriad-elf/include/c++/4.8.2/backward"


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


Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats

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

Ping :)


http://reviews.llvm.org/D14877



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


[PATCH] D15699: [cfi] Cross-DSO CFI diagnostic mode (clang part)

2015-12-21 Thread Evgeniy Stepanov via cfe-commits
eugenis created this revision.
eugenis added reviewers: pcc, kcc.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.

- Runtime diagnostic data for cfi-icall changed to match the rest of cfi checks
- Layout of all CFI diagnostic data changed to put Kind at the beginning. There 
is no ABI stability promise yet.
- call __cfi_slowpath_diag instead of __cfi_slowpath when needed.
- emit __cfi_check_fail function, which dispatches a CFI check faliure 
according to trap/recover settings of the current module.
- a tiny driver change to match the way the new handlers are done in 
compiler-rt.

Repository:
  rL LLVM

http://reviews.llvm.org/D15699

Files:
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  test/CodeGen/cfi-check-fail.c
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/CodeGenCXX/cfi-vcall.cpp

Index: test/CodeGenCXX/cfi-vcall.cpp
===
--- test/CodeGenCXX/cfi-vcall.cpp
+++ test/CodeGenCXX/cfi-vcall.cpp
@@ -55,7 +55,7 @@
 
 // DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}cfi-vcall.cpp\00", align 1
 // DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" }
-// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }*, i8 } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]], i8 0 }
+// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] }
 
 // ITANIUM: define void @_Z2afP1A
 // MS: define void @"\01?af@@YAXPEAUA@@@Z"
@@ -69,9 +69,9 @@
   // NDIAG-NEXT: call void @llvm.trap()
   // NDIAG-NEXT: unreachable
   // DIAG-NEXT: [[VTINT:%[^ ]*]] = ptrtoint i8* [[VT]] to i64
-  // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_bad_type_abort(i8* bitcast ({{.*}} @[[BADTYPESTATIC]] to i8*), i64 [[VTINT]])
+  // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]])
   // DIAG-ABORT-NEXT: unreachable
-  // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_bad_type(i8* bitcast ({{.*}} @[[BADTYPESTATIC]] to i8*), i64 [[VTINT]])
+  // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]])
   // DIAG-RECOVER-NEXT: br label %[[CONTBB]]
 
   // CHECK: [[CONTBB]]
Index: test/CodeGenCXX/cfi-cross-dso.cpp
===
--- test/CodeGenCXX/cfi-cross-dso.cpp
+++ test/CodeGenCXX/cfi-cross-dso.cpp
@@ -34,8 +34,8 @@
 // MS:   %[[TEST:.*]] = call i1 @llvm.bitset.test(i8* %[[VT2]], metadata !"?AUA@@"), !nosanitize
 // CHECK:   br i1 %[[TEST]], label %[[CONT:.*]], label %[[SLOW:.*]], {{.*}} !nosanitize
 // CHECK: [[SLOW]]
-// ITANIUM:   call void @__cfi_slowpath(i64 7004155349499253778, i8* %[[VT2]]) {{.*}} !nosanitize
-// MS:   call void @__cfi_slowpath(i64 -8005289897957287421, i8* %[[VT2]]) {{.*}} !nosanitize
+// ITANIUM:   call void @__cfi_slowpath_diag(i64 7004155349499253778, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
+// MS:   call void @__cfi_slowpath_diag(i64 -8005289897957287421, i8* %[[VT2]], {{.*}}) {{.*}} !nosanitize
 // CHECK:   br label %[[CONT]], !nosanitize
 // CHECK: [[CONT]]
 // CHECK:   call void %{{.*}}(%struct.A* %{{.*}})
Index: test/CodeGen/cfi-icall-cross-dso.c
===
--- test/CodeGen/cfi-icall-cross-dso.c
+++ test/CodeGen/cfi-icall-cross-dso.c
@@ -19,11 +19,16 @@
 inline void foo() {}
 void bar() { foo(); }
 
+// CHECK: @[[SRC:.*]] = private unnamed_addr constant {{.*}}cfi-icall-cross-dso.c\00
+// CHECK: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [{{.*}} x i8] } { i16 -1, i16 0, [{{.*}} x i8] c"'void ()'\00"
+// CHECK: @[[DATA:.*]] = private unnamed_addr global {{.*}}@[[SRC]]{{.*}}@[[TYPE]]
+
+
 // ITANIUM: call i1 @llvm.bitset.test(i8* %{{.*}}, metadata !"_ZTSFvE"), !nosanitize
-// ITANIUM: call void @__cfi_slowpath(i64 6588678392271548388, i8* %{{.*}}) {{.*}}, !nosanitize
+// ITANIUM: call void @__cfi_slowpath_diag(i64 6588678392271548388, i8* %{{.*}}, {{.*}}@[[DATA]]{{.*}}, !nosanitize
 
 // MS: call i1 @llvm.bitset.test(i8* %{{.*}}, metadata !"?6AX@Z"), !nosanitize
-// MS: call void @__cfi_slowpath(i64 4195979634929632483, i8* %{{.*}}) {{.*}}, !nosanitize
+// MS: call void @__cfi_slowpath_diag(i64 4195979634929632483, i8* %{{.*}}, {{.*}}@[[DATA]]{{.*}}, !nosanitize
 
 // ITANIUM: define available_externally void @foo()
 // MS: define linkonce_odr void @foo()
Index: 

Re: [PATCH] D15319: [Sema] Don't accept e.g. "(int *)(long)" as a constant expression if x is in address space != 0.

2015-12-21 Thread Manuel Jacob via cfe-commits
mjacob added a comment.

ping


http://reviews.llvm.org/D15319



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


Re: [PATCH] D12299: [libcxx] Fix for ALL undefined behavior in .

2015-12-21 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Ping.


http://reviews.llvm.org/D12299



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


[PATCH] D15705: Adding a scripted test for PR25717

2015-12-21 Thread Yunzhong Gao via cfe-commits
ygao created this revision.
ygao added subscribers: cfe-commits, rsandifo, majnemer, aaron.ballman.

Hi,
I am trying to add a test for PR25717. The test itself is fairly 
straight-forward: it generates a
large .c temporary file on the fly and then runs the preprocessor over the 
generated file to
make sure we do not see any unexpected fatal errors.
I have never added a scripted test before, so it would be really nice if 
someone with this
experience could take a look that I did make all the necessary changes.
Many thanks in advance,
- Gao

http://reviews.llvm.org/D15705

Files:
  test/Preprocessor/bigoutput.py
  test/Preprocessor/lit.local.cfg

Index: test/Preprocessor/lit.local.cfg
===
--- test/Preprocessor/lit.local.cfg
+++ test/Preprocessor/lit.local.cfg
@@ -0,0 +1,2 @@
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.cl', '.s', '.S', '.py']
+
Index: test/Preprocessor/bigoutput.py
===
--- test/Preprocessor/bigoutput.py
+++ test/Preprocessor/bigoutput.py
@@ -0,0 +1,11 @@
+# RUN: python %s
+# RUN: %clang_cc1 -E -x c bigoutput.c | FileCheck %s
+
+# Make sure clang does not crash during preprocessing
+# CHECK-NOT: fatal error
+
+f = open("bigoutput.c", "wb")
+for i in range(0, 15000):
+  # this test requires UNIX line endings
+  f.write("int v%d;\n" % i)
+f.close()


Index: test/Preprocessor/lit.local.cfg
===
--- test/Preprocessor/lit.local.cfg
+++ test/Preprocessor/lit.local.cfg
@@ -0,0 +1,2 @@
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.cl', '.s', '.S', '.py']
+
Index: test/Preprocessor/bigoutput.py
===
--- test/Preprocessor/bigoutput.py
+++ test/Preprocessor/bigoutput.py
@@ -0,0 +1,11 @@
+# RUN: python %s
+# RUN: %clang_cc1 -E -x c bigoutput.c | FileCheck %s
+
+# Make sure clang does not crash during preprocessing
+# CHECK-NOT: fatal error
+
+f = open("bigoutput.c", "wb")
+for i in range(0, 15000):
+  # this test requires UNIX line endings
+  f.write("int v%d;\n" % i)
+f.close()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15704: Add some overlooked optnone tests, and tighten up an existing test

2015-12-21 Thread Paul Robinson via cfe-commits
probinson created this revision.
probinson added a reviewer: aaron.ballman.
probinson added a subscriber: cfe-commits.

Found some tests we wrote back in the day, but which never made it upstream.

optnone-and-attributes.cpp is a more thorough exercise of optnone attribute 
interaction than we have currently.

I'm not entirely sure about the value of optnone-class-members.cpp and 
optnone-templates.cpp as these would seem to be really exercising the main 
attribute handling in the context of classes, inheritance, and template 
instantiation; not really that specific to optnone, but it's hard to tell 
whether general attribute handling tests cover these situations.  I'm happy to 
contribute them, or throw them away.

The tweak to optnone-def-decl.cpp just makes that last CHECK do what we 
actually meant it to.

http://reviews.llvm.org/D15704

Files:
  test/CodeGenCXX/optnone-and-attributes.cpp
  test/CodeGenCXX/optnone-class-members.cpp
  test/CodeGenCXX/optnone-def-decl.cpp
  test/CodeGenCXX/optnone-templates.cpp

Index: test/CodeGenCXX/optnone-templates.cpp
===
--- test/CodeGenCXX/optnone-templates.cpp
+++ test/CodeGenCXX/optnone-templates.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | FileCheck %s
+
+// Test optnone on template instantiations.
+
+//-- Effect of optnone on generic add template function.
+
+template  T template_normal(T a)
+{
+  return a + a;
+}
+
+template  __attribute__((optnone)) T template_optnone(T a)
+{
+  return a + a + a;
+}
+
+// This function should cause instantiations of each template, one marked
+// with the 'optnone' attribute.
+int container(int i)
+{
+  return template_normal(i) + template_optnone(i);
+}
+
+// CHECK: @_Z15template_normalIiET_S0_({{.*}}) [[NORMAL:#[0-9]+]]
+// CHECK: @_Z16template_optnoneIiET_S0_({{.*}}) [[OPTNONE:#[0-9]+]]
+
+
+//-- Effect of optnone on a partial specialization.
+//   FIRST TEST: a method becomes marked with optnone in the specialization.
+
+template  class template_normal_base {
+public:
+  T method(T t, U u) 
+  {
+return t + static_cast(u);
+  }
+};
+
+template  class template_normal_base
+{
+public:
+  __attribute__((optnone)) int method (int t, U u)
+  {
+return t - static_cast(u);
+  }
+};
+
+// This function should cause an instantiation of the full template (whose
+// method is not marked optnone) and an instantiation of the partially
+// specialized template (whose method is marked optnone).
+void container2() 
+{
+  int y = 2;
+  float z = 3.0;
+  template_normal_base class_normal;
+  template_normal_base class_optnone;
+  float r1 = class_normal.method(z, y);
+  float r2 = class_optnone.method(y, z);
+}
+
+// CHECK: @_ZN20template_normal_baseIfiE6methodEfi({{.*}}) [[NORMAL]]
+// CHECK: @_ZN20template_normal_baseIifE6methodEif({{.*}}) [[OPTNONE]]
+
+
+//-- Effect of optnone on a partial specialization.
+//   SECOND TEST: a method loses optnone in the specialization.
+
+template  class template_optnone_base {
+public:
+  __attribute__((optnone)) T method(T t, U u) 
+  {
+return t + static_cast(u);
+  }
+};
+
+template  class template_optnone_base
+{
+public:
+  int method (int t, U u)
+  {
+return t - static_cast(u);
+  }
+};
+
+// This function should cause an instantiation of the full template (whose
+// method is marked optnone) and an instantiation of the partially
+// specialized template (whose method is not marked optnone).
+void container3() 
+{
+  int y = 2;
+  float z = 3.0;
+  template_optnone_base class_optnone;
+  template_optnone_base class_normal;
+  float r1 = class_optnone.method(z, y);
+  float r2 = class_normal.method(y, z);
+}
+
+// CHECK: @_ZN21template_optnone_baseIfiE6methodEfi({{.*}}) [[OPTNONE]]
+// CHECK: @_ZN21template_optnone_baseIifE6methodEif({{.*}}) [[NORMAL]]
+
+
+// CHECK: attributes [[NORMAL]] =
+// CHECK-SAME-NOT: optnone
+// CHECK: attributes [[OPTNONE]] = {{.*}} optnone
Index: test/CodeGenCXX/optnone-def-decl.cpp
===
--- test/CodeGenCXX/optnone-def-decl.cpp
+++ test/CodeGenCXX/optnone-def-decl.cpp
@@ -90,5 +90,6 @@
 // CHECK: @_Z28forceinline_optnone_functionii({{.*}}) [[OPTNONE]]
 
 // CHECK: attributes [[OPTNONE]] = { noinline nounwind optnone {{.*}} }
-// CHECK: attributes [[NORMAL]] = { nounwind {{.*}} }
-
+// CHECK: attributes [[NORMAL]] =
+// CHECK-SAME-NOT: noinline
+// CHECK-SAME-NOT: optnone
Index: test/CodeGenCXX/optnone-class-members.cpp
===
--- test/CodeGenCXX/optnone-class-members.cpp
+++ test/CodeGenCXX/optnone-class-members.cpp
@@ -0,0 +1,164 @@
+// RUN: %clang_cc1 < %s -triple %itanium_abi_triple -fms-extensions -emit-llvm -x c++ | FileCheck %s
+
+// Test attribute 'optnone' on methods:
+//  -- member functions;
+//  -- static member functions.
+
+// Verify 

Re: [PATCH] D15613: Fix ARM __cxa_end_cleanup() and gc-sections.

2015-12-21 Thread Eric Christopher via cfe-commits
echristo added a comment.

Sure, I don't care enough either way :)

-eric


http://reviews.llvm.org/D15613



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


Re: [PATCH] D15705: Adding a scripted test for PR25717

2015-12-21 Thread Yunzhong Gao via cfe-commits
ygao added inline comments.


Comment at: test/Preprocessor/bigoutput.py:7
@@ +6,3 @@
+
+f = open("bigoutput.c", "wb")
+for i in range(0, 15000):

For example, it would be nice to use %t as the temporary file name (so lit will 
fill in with a generated
name) instead of a hard-coded name here, but I am trying to force UNIX line 
ending here. So I could
not figure out how to combine %t with the open() call.


http://reviews.llvm.org/D15705



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


r256204 - [clang-cl] Add support for /Brepro

2015-12-21 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Dec 21 16:09:34 2015
New Revision: 256204

URL: http://llvm.org/viewvc/llvm-project?rev=256204=rev
Log:
[clang-cl] Add support for /Brepro

The /Brepro flag controls whether or not the compiler should embed
timestamps into the object file.  Object files which do not embed
timestamps are not suitable for incremental linking but are suitable for
hermetic build systems and staged self-hosts of clang.

A normal clang spelling of this flag has been added,
-mincremental-linker-compatible.

Added:
cfe/trunk/test/Driver/incremental-linker-compatible.c
Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/cl-options.c
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=256204=256203=256204=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Mon Dec 21 16:09:34 2015
@@ -52,6 +52,12 @@ class CLRemainingArgs : Opt
 // (We don't put any of these in cl_compile_Group as the options they alias are
 // already in the right group.)
 
+def _SLASH_Brepro : CLFlag<"Brepro">,
+  HelpText<"Emit an object file which can be reproduced over time">,
+  Alias;
+def _SLASH_Brepro_ : CLFlag<"Brepro-">,
+  HelpText<"Emit an object file which cannot be reproduced over time">,
+  Alias;
 def _SLASH_C : CLFlag<"C">,
   HelpText<"Don't discard comments when preprocessing">, Alias;
 def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=256204=256203=256204=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Dec 21 16:09:34 2015
@@ -1459,6 +1459,11 @@ def mred_zone : Flag<["-"], "mred-zone">
 def mregparm_EQ : Joined<["-"], "mregparm=">, Group;
 def mrelax_all : Flag<["-"], "mrelax-all">, Group, 
Flags<[CC1Option,CC1AsOption]>,
   HelpText<"(integrated-as) Relax all machine instructions">;
+def mincremental_linker_compatible : Flag<["-"], 
"mincremental-linker-compatible">, Group,
+  Flags<[CC1Option,CC1AsOption]>,
+  HelpText<"(integrated-as) Emit an object file which can be used with an 
incremental linker">;
+def mno_incremental_linker_compatible : Flag<["-"], 
"mno-incremental-linker-compatible">, Group,
+  HelpText<"(integrated-as) Emit an object file which cannot be used with an 
incremental linker">;
 def mrtd : Flag<["-"], "mrtd">, Group, Flags<[CC1Option]>,
   HelpText<"Make StdCall calling convention the default">;
 def msmall_data_threshold_EQ : Joined <["-"], "msmall-data-threshold=">, 
Group;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=256204=256203=256204=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Dec 21 16:09:34 2015
@@ -75,6 +75,9 @@ CODEGENOPT(PrepareForLTO , 1, 0) ///
  ///< compile step.
 CODEGENOPT(EmitFunctionSummary, 1, 0) ///< Set when -flto=thin is enabled on 
the
   ///< compile step.
+CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which 
can
+  ///< be used with an incremental
+  ///< linker.
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=256204=256203=256204=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Dec 21 16:09:34 2015
@@ -571,6 +571,8 @@ TargetMachine *EmitAssemblyHelper::Creat
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
   Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
+  Options.MCOptions.MCIncrementalLinkerCompatible =
+

Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker

2015-12-21 Thread Andy Gibbs via cfe-commits
AndyG added a comment.

Richard, David,

Sorry, I've added you as reviewers by proximity to recent relevant changes in 
SemaChecking.cpp.  Hope you don't mind.  Please tell me who to redirect to, if 
there are more applicable reviewers.

Cheers
Andy


http://reviews.llvm.org/D15636



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


[clang-tools-extra] r256142 - Fix a false positive case in ContainerSizeEmpty check (PR25893).

2015-12-21 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Dec 21 03:43:52 2015
New Revision: 256142

URL: http://llvm.org/viewvc/llvm-project?rev=256142=rev
Log:
Fix a false positive case in ContainerSizeEmpty check (PR25893).

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp?rev=256142=256141=256142=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
Mon Dec 21 03:43:52 2015
@@ -126,6 +126,11 @@ void ContainerSizeEmptyCheck::check(cons
 (OpCode == BinaryOperatorKind::BO_LE && Value == 0 && !ContainerIsLHS))
   return;
 
+// Do not warn for size > 1, 1 < size.
+if ((OpCode == BinaryOperatorKind::BO_GT && Value == 1 && ContainerIsLHS) 
||
+(OpCode == BinaryOperatorKind::BO_LT && Value == 1 && !ContainerIsLHS))
+  return;
+
 if (OpCode == BinaryOperatorKind::BO_NE && Value == 0)
   Negation = true;
 if ((OpCode == BinaryOperatorKind::BO_GT ||

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp?rev=256142=256141=256142=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-container-size-empty.cpp 
Mon Dec 21 03:43:52 2015
@@ -50,6 +50,10 @@ int main() {
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: the 'empty' method should be 
used
   // CHECK-FIXES: {{^  }}if (!vect.empty()){{$}}
+  if (vect.size() > 1) // no warning
+;
+  if (1 < vect.size()) // no warning
+;
   if (!vect.size())
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: the 'empty' method should be used


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


Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-12-21 Thread Paul Robinson via cfe-commits
probinson added a comment.

The patch to expose debugger tuning to Clang was finished in r256104.  If you 
use the new -glldb option to clang, you should get these accelerator tables.  
I'm assuming you're using LLDB because I don't think any other debugger makes 
use of those tables, although that's admittedly a guess on my part.
If LLDB is the default system debugger for some target other than Darwin, then 
we should fiddle with the defaulting.

If -glldb satisfies your needs, then you can probably just abandon this review.


http://reviews.llvm.org/D14354



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


Re: [PATCH] D15674: [CodeGen] Fix assignments of inline layouts into the byref structure

2015-12-21 Thread John McCall via cfe-commits
rjmccall added a comment.

You don't need a CodeGenFunction for this; just use 
llvm::ConstantExpr::getBitCast.  Please document the requirement that this 
returns an i8* in CGObjCRuntime.h.


http://reviews.llvm.org/D15674



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


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-12-21 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Ping. What's the state of this?


http://reviews.llvm.org/D12407



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


r256154 - clang-format: [JS] Change Google-style default for aligning operands.

2015-12-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 21 07:52:19 2015
New Revision: 256154

URL: http://llvm.org/viewvc/llvm-project?rev=256154=rev
Log:
clang-format: [JS] Change Google-style default for aligning operands.

The style guide allows both, but apparently, this is the more dominant use.

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=256154=256153=256154=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 21 07:52:19 2015
@@ -578,6 +578,7 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.SpacesBeforeTrailingComments = 1;
   } else if (Language == FormatStyle::LK_JavaScript) {
 GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+GoogleStyle.AlignOperands = false;
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=256154=256153=256154=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Dec 21 07:52:19 2015
@@ -80,8 +80,8 @@ TEST_F(FormatTestJS, UnderstandsJavaScri
"  q();",
getGoogleJSStyleWithColumns(20));
   verifyFormat("var x = aa ?\n"
-   "bb :\n"
-   "ccc;",
+   "bb :\n"
+   "ccc;",
getGoogleJSStyleWithColumns(20));
 
   verifyFormat("var b = a.map((x) => x + 1);");
@@ -530,11 +530,11 @@ TEST_F(FormatTestJS, ArrowFunctions) {
"};");
   verifyFormat("var a = a.aaa(\n"
"(a: a) => a(b) &&\n"
-   "  a(bbb));");
+   "a(bbb));");
   verifyFormat("var a = a.aaa(\n"
"(a: a) => a(b) ?\n"
-   "  a(bbb) :\n"
-   "  a(bbb));");
+   "a(bbb) :\n"
+   "a(bbb));");
 
   // FIXME: This is bad, we should be wrapping before "() => {".
   verifyFormat("someFunction(() => {\n"
@@ -589,7 +589,7 @@ TEST_F(FormatTestJS, TryCatch) {
 
 TEST_F(FormatTestJS, StringLiteralConcatenation) {
   verifyFormat("var literal = 'hello ' +\n"
-   "  'world';");
+   "'world';");
 }
 
 TEST_F(FormatTestJS, RegexLiteralClassification) {
@@ -859,7 +859,7 @@ TEST_F(FormatTestJS, TemplateStrings) {
getGoogleJSStyleWithColumns(35)); // Barely fits.
   EXPECT_EQ("var x = `hello\n"
 "  ${world}` >=\n"
-"some();",
+"some();",
 format("var x =\n"
"`hello\n"
"  ${world}` >= some();",
@@ -884,7 +884,7 @@ TEST_F(FormatTestJS, TemplateStrings) {
   // are first token in line.
   verifyFormat(
   "var a =  ||\n"
-  "`a`;");
+  "`a`;");
 
   // Two template strings.
   verifyFormat("var x = `hello` == `hello`;");


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


[PATCH] D15685: [clang-tidy] introducing cppcoreguidelines-enum-all-caps check

2015-12-21 Thread Kirill Bobyrev via cfe-commits
omtcyf0 created this revision.
omtcyf0 added reviewers: alexfh, chapuni, klimek.
omtcyf0 added a subscriber: cfe-commits.

This patch introduces cppcoreguidelines-enum-all-caps, which flags all ALL_CAPS 
enumerations.

As written in C++ Core Guidelines: enumerations should not be named using 
ALL_CAPS to avoid clashes with macros.

This rule is part of the "Enumerations" profile of the C++ Core Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-enum5-dont-use-all_caps-for-enumerators

http://reviews.llvm.org/D15685

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/EnumAllCapsCheck.cpp
  clang-tidy/cppcoreguidelines/EnumAllCapsCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-enum-all-caps.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-enum-all-caps.cpp

Index: test/clang-tidy/cppcoreguidelines-enum-all-caps.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-enum-all-caps.cpp
@@ -0,0 +1,20 @@
+// RUN: clang-tidy -checks=cppcoreguidelines-enum-all-caps %s
+
+enum color {
+RED = 0xFF,
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Don’t use ALL_CAPS for enumerators [cppcoreguidelines-enum-all-caps]
+// CHECK-FIXES: red
+BLUE_COLOR = 0xFF,
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Don’t use ALL_CAPS for enumerators [cppcoreguidelines-enum-all-caps]
+// CHECK-FIXES: blue_color
+COOL_GREEN_123
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Don’t use ALL_CAPS for enumerators [cppcoreguidelines-enum-all-caps]
+// CHECK-FIXES: cool_green_123
+};
+
+// These are OK
+enum star_wars_character {
+  Chewbacca = 0,
+  Yoda = 1,
+  Darth_Vader = 2
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
cert-static-object-exception
cert-thrown-exception-type
cert-variadic-function-def
+   cppcoreguidelines-enum-all-caps
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: docs/clang-tidy/checks/cppcoreguidelines-enum-all-caps.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-enum-all-caps.rst
@@ -0,0 +1,9 @@
+cppcoreguidelines-enum-all-caps
+=
+
+This check flags all ALL_CAPS enumerations.
+
+Enumerations should not be named using ALL_CAPS to avoid clashes with macros.
+
+This rule is part of the "Enumerations" profile of the C++ Core Guidelines, see
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-enum5-dont-use-all_caps-for-enumerators
Index: clang-tidy/cppcoreguidelines/EnumAllCapsCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/EnumAllCapsCheck.h
@@ -0,0 +1,36 @@
+//===--- EnumAllCapsCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ENUMALLCAPS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ENUMALLCAPS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+/// This check flags all ALL_CAPS enumerations
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-enum-all-caps.html
+class EnumAllCapsCheck : public ClangTidyCheck {
+public:
+  EnumAllCapsCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace cppcoreguidelines
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ENUMALLCAPS_H
+
Index: clang-tidy/cppcoreguidelines/EnumAllCapsCheck.cpp
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/EnumAllCapsCheck.cpp
@@ -0,0 +1,55 @@
+//===--- EnumAllCapsCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "EnumAllCapsCheck.h"
+#include 

Re: [PATCH] D15664: Teaches clang about Exynos-M1

2015-12-21 Thread MinSeong KIM via cfe-commits
MinSeongKIM updated this revision to Diff 43354.
MinSeongKIM added a comment.
Herald added a subscriber: aemerson.

Code rewritten


http://reviews.llvm.org/D15664

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  test/CodeGen/arm-target-features.c
  test/Driver/aarch64-cpus.c
  test/Driver/arm-cortex-cpus.c
  test/Preprocessor/aarch64-target-features.c

Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -92,11 +92,13 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A53 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A57 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A72 %s
+// RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-M1 %s
 // CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
+// CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
 // CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -398,40 +398,48 @@
 // RUN: %clang -target arm -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=exynos-m1 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // CHECK-CPUV8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}
 
 // RUN: %clang -target armeb -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
+// RUN: %clang -target armeb -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
+// RUN: %clang -target arm -mcpu=exynos-m1 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // CHECK-BE-CPUV8A: "-cc1"{{.*}} "-triple" "armebv8-{{.*}}
 
 // RUN: %clang -target arm -mcpu=cortex-a35 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mthumb -### -c %s 2>&1 | FileCheck 

r256153 - clang-format: Only try to find the "main" include in the first block of

2015-12-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 21 07:40:49 2015
New Revision: 256153

URL: http://llvm.org/viewvc/llvm-project?rev=256153=rev
Log:
clang-format: Only try to find the "main" include in the first block of
includes.

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=256153=256152=256153=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 21 07:40:49 2015
@@ -1814,6 +1814,7 @@ tooling::Replacements sortIncludes(const
   FileName.endswith(".cxx") || FileName.endswith(".m") ||
   FileName.endswith(".mm");
   StringRef FileStem = llvm::sys::path::stem(FileName);
+  bool FirstIncludeBlock = true;
 
   // Create pre-compiled regular expressions for the #include categories.
   SmallVector CategoryRegexs;
@@ -1843,7 +1844,8 @@ tooling::Replacements sortIncludes(const
 break;
   }
 }
-if (IsSource && Category > 0 && IncludeName.startswith("\"")) {
+if (IsSource && Category > 0 && FirstIncludeBlock &&
+IncludeName.startswith("\"")) {
   StringRef HeaderStem =
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem))
@@ -1854,6 +1856,7 @@ tooling::Replacements sortIncludes(const
 sortIncludes(Style, IncludesInBlock, Ranges, FileName, Replaces,
  Cursor);
 IncludesInBlock.clear();
+FirstIncludeBlock = false;
   }
   Prev = Pos + 1;
 }

Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=256153=256152=256153=diff
==
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original)
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Mon Dec 21 07:40:49 2015
@@ -191,6 +191,19 @@ TEST_F(SortIncludesTest, LeavesMainHeade
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
  "a.h"));
+
+  // Only do this in the first #include block.
+  EXPECT_EQ("#include \n"
+"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n"
+"#include \"llvm/a.h\"\n",
+sort("#include \n"
+ "\n"
+ "#include \"llvm/a.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"b.h\"\n",
+ "a.cc"));
 }
 
 TEST_F(SortIncludesTest, NegativePriorities) {


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


r256228 - Use -no-canonical-prefixes to make sure binaries names are easier to match.

2015-12-21 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Mon Dec 21 19:45:45 2015
New Revision: 256228

URL: http://llvm.org/viewvc/llvm-project?rev=256228=rev
Log:
Use -no-canonical-prefixes to make sure binaries names are easier to match.

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=256228=256227=256228=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Dec 21 19:45:45 2015
@@ -1,3 +1,3 @@
-// RUN: %clang -### -target wasm32-unknown-unknown -x assembler %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown -x 
assembler %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}}" "-cc1as" {{.*}} "-o" "[[temp:[^"]*]]"
 // AS_LINK: lld" "-flavor" "ld" "[[temp]]" "-o" "a.out"


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


Re: [PATCH] D12502: [libcxx] Better constain tuples constructors -- Fix PR23256 and PR22806

2015-12-21 Thread Louis Dionne via cfe-commits
ldionne added a comment.

This LGTM. I also just confirmed that it fixes the original issue in Hana that 
caused me to report PR22806.


http://reviews.llvm.org/D12502



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


[PATCH] D15709: [X86] Support 'interrupt' attribute for x86

2015-12-21 Thread Alexey Bataev via cfe-commits
ABataev created this revision.
ABataev added reviewers: aaron.ballman, rjmccall.
ABataev added a subscriber: cfe-commits.

This attribute may be attached to a function definition and
instructs the backend to generate appropriate function entry/exit code so that
it can be used directly as an interrupt handler.
The ``IRET`` instruction, instead of the ``RET`` instruction, is used to return
from interrupt or exception handlers.  All registers, except for the ``EFLAGS``
register which is restored by the ``IRET`` instruction, are preserved by the
compiler.
Any interruptible-without-stack-switch code must be compiled with -mno-red-zone
since interrupt handlers can and will, because of the hardware design, touch
the red zone.

1. interrupt handler must be declared with a mandatory pointer argument:

  .. code-block:: c

struct interrupt_frame;

__attribute__ ((interrupt))
void f (struct interrupt_frame *frame) {
  ...
}

  and user must properly define the structure the pointer pointing to.

2. exception handler:

  The exception handler is very similar to the interrupt handler with
  a different mandatory function signature:

  .. code-block:: c

#ifdef __x86_64__
typedef unsigned long long int uword_t;
#else
typedef unsigned int uword_t;
#endif

struct interrupt_frame;

__attribute__ ((interrupt))
void f (struct interrupt_frame *frame, uword_t error_code) {
  ...
}

  and compiler pops the error code off stack before the 'IRET' instruction.

  The exception handler should only be used for exceptions which push an
  error code and all other exceptions must use the interrupt handler.
  The system will crash if the wrong handler is used.

http://reviews.llvm.org/D15709

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/attr-x86-interrupt.c
  test/Sema/attr-x86-interrupt.c

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1574,6 +1574,10 @@
   llvm::AttributeSet::FunctionIndex,
   B));
 }
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+}
   }
 }
 
@@ -1879,6 +1883,16 @@
 ('T' << 24);
 return llvm::ConstantInt::get(CGM.Int32Ty, Sig);
   }
+
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule ) const override {
+if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+  if (FD->hasAttr()) {
+llvm::Function *Fn = cast(GV);
+Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+  }
+}
+  }
 };
 
 class PS4TargetCodeGenInfo : public X86_64TargetCodeGenInfo {
@@ -1996,6 +2010,13 @@
 CodeGen::CodeGenModule ) const {
   TargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
 
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if (FD->hasAttr()) {
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::X86_INTR);
+}
+  }
+
   addStackProbeSizeTargetAttribute(D, GV, CGM);
 }
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -4969,6 +4969,10 @@
Fn->getValueKind(), FDecl);
   }
 }
+if (NDecl && NDecl->hasAttr()) {
+  Diag(Fn->getExprLoc(), diag::err_interrupt_function_called);
+  return ExprError();
+}
   } else if (isa(NakedFn))
 NDecl = cast(NakedFn)->getMemberDecl();
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4545,6 +4545,49 @@
   Attr.getLoc(), S.Context, Kind, Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleIAInterruptAttr(Sema , Decl *D, const AttributeList ) {
+  // Semantic checks for a function with the 'interrupt' attribute.
+  // a) Must be a function.
+  // b) Must have the 'void' return type.
+  // c) Must take 1 or 2 arguments.
+  // d) The 1st argument must be a pointer.
+  // e) The 2nd argument (if any) must be an unsigned integer.
+  if (!isFunctionOrMethod(D) || !hasFunctionProto(D) ||
+  !D->getDeclContext()->isFileContext()) {
+S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
+<< Attr.getName() << ExpectedFunction;
+return;
+  }
+  // Interrupt handler must have void return type.
+  if (!getFunctionOrMethodResultType(D)->isVoidType()) {
+S.Diag(getFunctionOrMethodResultSourceRange(D).getBegin(),
+   diag::err_interrupt_function_wrong_return_type);
+return;
+  }
+  // Interrupt 

Re: [PATCH] D15641: [Driver] Pass -O* to the gold plugin via -plugin-opt

2015-12-21 Thread James Molloy via cfe-commits
jmolloy accepted this revision.
jmolloy added a reviewer: jmolloy.
jmolloy added a comment.
This revision is now accepted and ready to land.

Hi,

As we got to the bottom of why this is actually needed, I committed this with 
the changes suggested by Rafael in r256146.

Cheers,

James


Repository:
  rL LLVM

http://reviews.llvm.org/D15641



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


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-12-21 Thread Manuel Klimek via cfe-commits
I think we'll want somebody to find out whether there are simpler ways to
implement this.

On Mon, Dec 21, 2015, 9:16 AM Daniel Jasper  wrote:

> djasper added a comment.
>
> Ping. What's the state of this?
>
>
> http://reviews.llvm.org/D12407
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-12-21 Thread Manuel Klimek via cfe-commits
klimek added a comment.

I think we'll want somebody to find out whether there are simpler ways to
implement this.


http://reviews.llvm.org/D12407



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


RE: r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2015-12-21 Thread Romanova, Katya via cfe-commits
Hi David,

Thank you so much for the review.
I copied and pasted the diff file. Let me know if it’s OK to commit.


>> Could/should this ^ just be: Opts.DebugExplicitImport = Triple.isPS4CPU(); ?
Done.

>> Extra semicolon here ^
Done.

>> And is there any reason not to just use nullptr here and elsewhere? Anything 
>> with the substring "PtrTy" in the name seems like it should be pointer-like 
>> and be convertible from nullptr_t, no? (what is DeclGroupPtrTy?)
No, it's not convertible from nullptr_t.

/home/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:68:12: error: could not 
cnvert ‘nullptr’ from ‘std::nullptr_t’ to ‘clang::Parser::DeclGroupPtrTy {aka 
clang::OpaquePtr}’
 return nullptr;



Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp (revision 256140)
+++ lib/Frontend/CompilerInvocation.cpp (working copy)
@@ -1,4 +1,4 @@
-//===--- CompilerInvocation.cpp 
---===//
+//===---
//
// The LLVM Compiler Infrastructure
//
@@ -417,8 +417,7 @@
   Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  if (Triple.isPS4CPU())
-Opts.DebugExplicitImport = true;
+  Opts.DebugExplicitImport = Triple.isPS4CPU();

   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
 Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp  (revision 256140)
+++ lib/Parse/ParseDeclCXX.cpp  (working copy)
@@ -65,7 +65,7 @@
   if (Tok.is(tok::code_completion)) {
 Actions.CodeCompleteNamespaceDecl(getCurScope());
 cutOffParsing();
-return DeclGroupPtrTy();;
+return DeclGroupPtrTy();
   }

   SourceLocation IdentLoc;


Thank you!
Katya.



From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Sunday, December 13, 2015 3:46 PM
To: Romanova, Katya
Cc: cfe-commits
Subject: Re: r255281 - Do not generate DW_TAG_imported_module for anonymous 
namespaces (even nested) for all the platforms except PS4.



On Thu, Dec 10, 2015 at 10:52 AM, Ekaterina Romanova via cfe-commits 
> wrote:
Author: kromanova
Date: Thu Dec 10 12:52:50 2015
New Revision: 255281

URL: http://llvm.org/viewvc/llvm-project?rev=255281=rev
Log:
Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) 
for all the platforms except PS4.
For PS4, generate explicit import for anonymous namespaces and mark it by 
DW_AT_artificial attribute.

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


Added:
cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10 12:52:50 2015
@@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
 CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should 
contain
///< external references to a PCH or module.

+CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info should
+   ///< contain explicit imports for
+   ///< anonymous namespaces
+
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.

 /// The user specified number of registers to be used for integral arguments,

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 10 12:52:50 2015
@@ -2337,8 +2337,8 @@ private:

   void DiagnoseUnexpectedNamespace(NamedDecl *Context);

-  Decl *ParseNamespace(unsigned Context, SourceLocation ,
-   SourceLocation InlineLoc = SourceLocation());
+  DeclGroupPtrTy ParseNamespace(unsigned Context, SourceLocation ,
+SourceLocation InlineLoc = SourceLocation());
   void 

r256146 - [Driver] Pass -O* to the gold plugin via -plugin-opt

2015-12-21 Thread James Molloy via cfe-commits
Author: jamesm
Date: Mon Dec 21 04:44:36 2015
New Revision: 256146

URL: http://llvm.org/viewvc/llvm-project?rev=256146=rev
Log:
[Driver] Pass -O* to the gold plugin via -plugin-opt

The gold plugin understands -O0..-O3, but these are not currently being passed 
to it.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/gold-lto.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256146=256145=256146=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 21 04:44:36 2015
@@ -1796,6 +1796,19 @@ static void AddGoldPlugin(const ToolChai
   if (!CPU.empty())
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=mcpu=") + CPU));
 
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+StringRef OOpt;
+if (A->getOption().matches(options::OPT_O4) ||
+A->getOption().matches(options::OPT_Ofast))
+  OOpt = "3";
+else if (A->getOption().matches(options::OPT_O))
+  OOpt = A->getValue();
+else if (A->getOption().matches(options::OPT_O0))
+  OOpt = "0";
+if (!OOpt.empty())
+  CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
+  }
+
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
 }

Modified: cfe/trunk/test/Driver/gold-lto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto.c?rev=256146=256145=256146=diff
==
--- cfe/trunk/test/Driver/gold-lto.c (original)
+++ cfe/trunk/test/Driver/gold-lto.c Mon Dec 21 04:44:36 2015
@@ -1,23 +1,26 @@
 // RUN: touch %t.o
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo \
+// RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
 // CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -march=corei7 -Wl,-plugin-opt=foo \
+// RUN: -march=corei7 -Wl,-plugin-opt=foo -Ofast \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
 // CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
 // CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
+// CHECK-X86-64-COREI7: "-plugin-opt=O3"
 // CHECK-X86-64-COREI7: "-plugin-opt=foo"
 //
 // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -march=armv7a -Wl,-plugin-opt=foo \
+// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
 // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
 // CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8"
+// CHECK-ARM-V7A: "-plugin-opt=O0"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
 //
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \


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


r256150 - [scan-view] replace deprecated optparse with argparse

2015-12-21 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Dec 21 06:19:13 2015
New Revision: 256150

URL: http://llvm.org/viewvc/llvm-project?rev=256150=rev
Log:
[scan-view] replace deprecated optparse with argparse

Summary: scan-view migrated from optparse deprecated Python module to its 
replacement (argparse) and resolved few conflicts with pep8

Reviewers: ddunbar, aaron.ballman, dcoughlin, jroelofs, zaks.anna

Subscribers: cfe-commits

Patch by Kirill Bobyrev!

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

Modified:
cfe/trunk/tools/scan-view/bin/scan-view

Modified: cfe/trunk/tools/scan-view/bin/scan-view
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/bin/scan-view?rev=256150=256149=256150=diff
==
--- cfe/trunk/tools/scan-view/bin/scan-view (original)
+++ cfe/trunk/tools/scan-view/bin/scan-view Mon Dec 21 06:19:13 2015
@@ -24,6 +24,7 @@ kMaxPortsToTry = 100
 
 ###
 
+
 def url_is_up(url):
 try:
 o = urllib.urlopen(url)
@@ -32,11 +33,13 @@ def url_is_up(url):
 o.close()
 return True
 
+
 def start_browser(port, options):
-import urllib, webbrowser
+import urllib
+import webbrowser
+
+url = 'http://%s:%d' % (options.host, port)
 
-url = 'http://%s:%d'%(options.host, port)
-
 # Wait for server to start...
 if options.debug:
 sys.stderr.write('%s: Waiting for server.' % sys.argv[0])
@@ -49,24 +52,25 @@ def start_browser(port, options):
 sys.stderr.flush()
 time.sleep(kSleepTimeout)
 else:
-print >>sys.stderr,'WARNING: Unable to detect that server started.'
+print >> sys.stderr, 'WARNING: Unable to detect that server started.'
 
 if options.debug:
-print >>sys.stderr,'%s: Starting webbrowser...' % sys.argv[0]
+print >> sys.stderr, '%s: Starting webbrowser...' % sys.argv[0]
 webbrowser.open(url)
 
+
 def run(port, options, root):
 # Prefer to look relative to the installed binary
 share = os.path.dirname(__file__) + "/../share/scan-view"
 if not os.path.isdir(share):
-  # Otherwise look relative to the source
-  share = os.path.dirname(__file__) + "/../../scan-view/share"
+# Otherwise look relative to the source
+share = os.path.dirname(__file__) + "/../../scan-view/share"
 sys.path.append(share)
 
 import ScanView
 try:
-print 'Starting scan-view at: http://%s:%d'%(options.host,
- port)
+print 'Starting scan-view at: http://%s:%d' % (options.host,
+   port)
 print '  Use Ctrl-C to exit.'
 httpd = ScanView.create_server((options.host, port),
options, root)
@@ -74,67 +78,66 @@ def run(port, options, root):
 except KeyboardInterrupt:
 pass
 
+
 def port_is_open(port):
 import SocketServer
 try:
-t = SocketServer.TCPServer((kDefaultHost,port),None)
+t = SocketServer.TCPServer((kDefaultHost, port), None)
 except:
 return False
 t.server_close()
 return True
 
-def main():
-from optparse import OptionParser
-parser = OptionParser('usage: %prog [options] ')
-parser.set_description(__doc__)
-parser.add_option(
-'--host', dest="host", default=kDefaultHost, type="string",
+
+def main():
+import argparse
+parser = argparse.ArgumentParser(description="The clang static analyzer "
+ "results viewer.")
+parser.add_argument("root", metavar="", type=str)
+parser.add_argument(
+'--host', dest="host", default=kDefaultHost, type=str,
 help="Host interface to listen on. (default=%s)" % kDefaultHost)
-parser.add_option(
-'--port', dest="port", default=None, type="int",
-help="Port to listen on. (default=%s)" % kDefaultPort)
-parser.add_option("--debug", dest="debug", default=0, 
-  action="count",
-  help="Print additional debugging information.")
-parser.add_option("--auto-reload", dest="autoReload", default=False, 
-  action="store_true",
-  help="Automatically update module for each request.")
-parser.add_option("--no-browser", dest="startBrowser", default=True, 
-  action="store_false",
-  help="Don't open a webbrowser on startup.")
-parser.add_option("--allow-all-hosts", dest="onlyServeLocal", 
default=True, 
-  action="store_false",
-  help='Allow connections from any host (access restricted 
to "127.0.0.1" by default)')
-(options, args) = parser.parse_args()
-
-if len(args) != 1:
-parser.error('No results directory specified.')
-root, = args
+parser.add_argument('--port', dest="port", default=None, type=int,
+ 

Re: [PATCH] D15370: [scan-view] replace deprecated optparse with argparse

2015-12-21 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256150: [scan-view] replace deprecated optparse with 
argparse (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D15370?vs=42636=43358#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15370

Files:
  cfe/trunk/tools/scan-view/bin/scan-view

Index: cfe/trunk/tools/scan-view/bin/scan-view
===
--- cfe/trunk/tools/scan-view/bin/scan-view
+++ cfe/trunk/tools/scan-view/bin/scan-view
@@ -24,19 +24,22 @@
 
 ###
 
+
 def url_is_up(url):
 try:
 o = urllib.urlopen(url)
 except IOError:
 return False
 o.close()
 return True
 
+
 def start_browser(port, options):
-import urllib, webbrowser
+import urllib
+import webbrowser
+
+url = 'http://%s:%d' % (options.host, port)
 
-url = 'http://%s:%d'%(options.host, port)
-
 # Wait for server to start...
 if options.debug:
 sys.stderr.write('%s: Waiting for server.' % sys.argv[0])
@@ -49,92 +52,92 @@
 sys.stderr.flush()
 time.sleep(kSleepTimeout)
 else:
-print >>sys.stderr,'WARNING: Unable to detect that server started.'
+print >> sys.stderr, 'WARNING: Unable to detect that server started.'
 
 if options.debug:
-print >>sys.stderr,'%s: Starting webbrowser...' % sys.argv[0]
+print >> sys.stderr, '%s: Starting webbrowser...' % sys.argv[0]
 webbrowser.open(url)
 
+
 def run(port, options, root):
 # Prefer to look relative to the installed binary
 share = os.path.dirname(__file__) + "/../share/scan-view"
 if not os.path.isdir(share):
-  # Otherwise look relative to the source
-  share = os.path.dirname(__file__) + "/../../scan-view/share"
+# Otherwise look relative to the source
+share = os.path.dirname(__file__) + "/../../scan-view/share"
 sys.path.append(share)
 
 import ScanView
 try:
-print 'Starting scan-view at: http://%s:%d'%(options.host,
- port)
+print 'Starting scan-view at: http://%s:%d' % (options.host,
+   port)
 print '  Use Ctrl-C to exit.'
 httpd = ScanView.create_server((options.host, port),
options, root)
 httpd.serve_forever()
 except KeyboardInterrupt:
 pass
 
+
 def port_is_open(port):
 import SocketServer
 try:
-t = SocketServer.TCPServer((kDefaultHost,port),None)
+t = SocketServer.TCPServer((kDefaultHost, port), None)
 except:
 return False
 t.server_close()
 return True
 
-def main():
-from optparse import OptionParser
-parser = OptionParser('usage: %prog [options] ')
-parser.set_description(__doc__)
-parser.add_option(
-'--host', dest="host", default=kDefaultHost, type="string",
+
+def main():
+import argparse
+parser = argparse.ArgumentParser(description="The clang static analyzer "
+ "results viewer.")
+parser.add_argument("root", metavar="", type=str)
+parser.add_argument(
+'--host', dest="host", default=kDefaultHost, type=str,
 help="Host interface to listen on. (default=%s)" % kDefaultHost)
-parser.add_option(
-'--port', dest="port", default=None, type="int",
-help="Port to listen on. (default=%s)" % kDefaultPort)
-parser.add_option("--debug", dest="debug", default=0, 
-  action="count",
-  help="Print additional debugging information.")
-parser.add_option("--auto-reload", dest="autoReload", default=False, 
-  action="store_true",
-  help="Automatically update module for each request.")
-parser.add_option("--no-browser", dest="startBrowser", default=True, 
-  action="store_false",
-  help="Don't open a webbrowser on startup.")
-parser.add_option("--allow-all-hosts", dest="onlyServeLocal", default=True, 
-  action="store_false",
-  help='Allow connections from any host (access restricted to "127.0.0.1" by default)')
-(options, args) = parser.parse_args()
-
-if len(args) != 1:
-parser.error('No results directory specified.')
-root, = args
+parser.add_argument('--port', dest="port", default=None, type=int,
+help="Port to listen on. (default=%s)" % kDefaultPort)
+parser.add_argument("--debug", dest="debug", default=0,
+action="count",
+help="Print additional debugging information.")
+parser.add_argument("--auto-reload", dest="autoReload", default=False,
+action="store_true",
+help="Automatically update module 

Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2015-12-21 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:1235-1236
@@ -1235,8 +1234,4 @@
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, 
/*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::GlobalValue *GV =
+cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
 

Artem, to address your concern (from http://reviews.llvm.org/rL254195#39417): 
if IsForDefinition equals to true, it is guaranteed that we get GlobalValue 
here. We specifically call GetAddrOfGlobal to create (or get) a global with 
required type, not cast from a declaration with a different type.


http://reviews.llvm.org/D15686



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


[PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2015-12-21 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rjmccall, tra.
andreybokhanko added a subscriber: cfe-commits.

This patch fixes incorrect behavior described in PR25910.

It is essentially the same stuff as in http://reviews.llvm.org/D11297, just for 
variables, not functions.

Yours,
Andrey

Software Engineer
Intel Compiler Team
Intel

http://reviews.llvm.org/D15686

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1226,27 +1226,22 @@
 
   for (DeferredGlobal  : CurDeclsToEmit) {
 GlobalDecl D = G.GD;
-llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
 // We should call GetAddrOfGlobal with IsForDefinition set to true in order
 // to get GlobalValue with exactly the type we need, not something that
 // might had been created for another decl with the same mangled name but
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::GlobalValue *GV =
+cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
 // deferred-decls queue multiple times, and second, decls can end
 // up with definitions in unusual ways (e.g. by an extern inline
 // function acquiring a strong function redefinition).  Just
 // ignore these cases.
-if (GV && !GV->isDeclaration())
+if (!GV->isDeclaration())
   continue;
 
 // Otherwise, emit the definition and move on to the next one.
@@ -1707,7 +1702,7 @@
   }
 
   if (const auto *VD = dyn_cast(D))
-return EmitGlobalVarDefinition(VD);
+return EmitGlobalVarDefinition(VD, !VD->hasDefinition());
   
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
@@ -1748,8 +1743,8 @@
 // error.
 if (IsForDefinition && !Entry->isDeclaration()) {
   GlobalDecl OtherGD;
-  // Check that GD is not yet in ExplicitDefinitions is required to make
-  // sure that we issue an error only once.
+  // Check that GD is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
   if (lookupRepresentativeDecl(MangledName, OtherGD) &&
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
@@ -1962,7 +1957,8 @@
 llvm::Constant *
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool IsForDefinition) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -1978,19 +1974,57 @@
 if (Entry->getType() == Ty)
   return Entry;
 
+// If there are two attempts to define the same mangled name, issue an
+// error.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  const VarDecl *OtherD;
+
+  // Check that D is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
+  (OtherD = dyn_cast(OtherGD.getDecl())) &&
+  OtherD->hasInit() &&
+  DiagnosedConflictingDefinitions.insert(D).second) {
+getDiags().Report(D->getLocation(),
+  diag::err_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
 // Make sure the result is of the correct type.
 if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
   return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
 
-return llvm::ConstantExpr::getBitCast(Entry, Ty);
+// Make sure the result is of the correct type.
+// (If global is requested for a definition, we always need to create a new
+// global, not just return a bitcast.)
+if (!IsForDefinition)
+  return llvm::ConstantExpr::getBitCast(Entry, Ty);
   }
 
   unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace());
   auto *GV = new llvm::GlobalVariable(
   getModule(), Ty->getElementType(), false,
   llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr,
   llvm::GlobalVariable::NotThreadLocal, AddrSpace);
 
+  // If we already 

r256148 - clang-format: Extend detection of the "main" #include to use the filename

2015-12-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 21 06:14:17 2015
New Revision: 256148

URL: http://llvm.org/viewvc/llvm-project?rev=256148=rev
Log:
clang-format: Extend detection of the "main" #include to use the filename

Before, the first (non-system) header in a file was considered to be
the main include. This is conservative as it makes clang-format change
the #include order less often. Instead implement some basic usage of
the filename itself. With this patch, clang-format considers every
header to be a main include if the header file's basename is a prefix
to the filename the #include is in.

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=256148=256147=256148=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 21 06:14:17 2015
@@ -1809,13 +1809,11 @@ tooling::Replacements sortIncludes(const
   //
   // FIXME: Do some sanity checking, e.g. edit distance of the base name, to 
fix
   // cases where the first #include is unlikely to be the main header.
-  bool LookForMainHeader = FileName.endswith(".c") ||
-   FileName.endswith(".cc") ||
-   FileName.endswith(".cpp")||
-   FileName.endswith(".c++")||
-   FileName.endswith(".cxx") ||
-   FileName.endswith(".m")||
-   FileName.endswith(".mm");
+  bool IsSource = FileName.endswith(".c") || FileName.endswith(".cc") ||
+  FileName.endswith(".cpp") || FileName.endswith(".c++") ||
+  FileName.endswith(".cxx") || FileName.endswith(".m") ||
+  FileName.endswith(".mm");
+  StringRef FileStem = llvm::sys::path::stem(FileName);
 
   // Create pre-compiled regular expressions for the #include categories.
   SmallVector CategoryRegexs;
@@ -1838,19 +1836,19 @@ tooling::Replacements sortIncludes(const
 if (!FormattingOff && !Line.endswith("\\")) {
   if (IncludeRegex.match(Line, )) {
 StringRef IncludeName = Matches[2];
-int Category;
-if (LookForMainHeader && !IncludeName.startswith("<")) {
-  Category = 0;
-} else {
-  Category = INT_MAX;
-  for (unsigned i = 0, e = CategoryRegexs.size(); i != e; ++i) {
-if (CategoryRegexs[i].match(IncludeName)) {
-  Category = Style.IncludeCategories[i].Priority;
-  break;
-}
+int Category = INT_MAX;
+for (unsigned i = 0, e = CategoryRegexs.size(); i != e; ++i) {
+  if (CategoryRegexs[i].match(IncludeName)) {
+Category = Style.IncludeCategories[i].Priority;
+break;
   }
 }
-LookForMainHeader = false;
+if (IsSource && Category > 0 && IncludeName.startswith("\"")) {
+  StringRef HeaderStem =
+  llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
+  if (FileStem.startswith(HeaderStem))
+Category = 0;
+}
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});
   } else if (!IncludesInBlock.empty()) {
 sortIncludes(Style, IncludesInBlock, Ranges, FileName, Replaces,

Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=256148=256147=256148=diff
==
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original)
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Mon Dec 21 06:14:17 2015
@@ -166,13 +166,21 @@ TEST_F(SortIncludesTest, LeavesMainHeade
 "#include \"c.h\"\n",
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
- "#include \"b.h\"\n"));
+ "#include \"b.h\"\n",
+ "a.cc"));
   EXPECT_EQ("#include \"llvm/a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ "a_main.cc"));
+  EXPECT_EQ("#include \"llvm/input.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"llvm/input.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"b.h\"\n",
  "input.mm"));
 
   // Don't do this in headers.
@@ -182,15 +190,27 @@ TEST_F(SortIncludesTest, LeavesMainHeade
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
- "some_header.h"));
+ "a.h"));
 }
 
 TEST_F(SortIncludesTest, 

Re: [PATCH] D15685: [clang-tidy] introducing cppcoreguidelines-enum-all-caps check

2015-12-21 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

There's already the readability-identifier-naming 

 check that is highly configurable. It might miss the "use any naming style 
except for this one" functionality, but I'd prefer it to be added to that check 
rather than implementing another check for naming styles. After the required 
functionality is added to the readability-identifier-naming check, we can just 
register it in the cppcoreguidelines module with a custom name (corresponding 
to the rule) and a custom configuration that only enables verification of 
enumerator names (see `GoogleModule::getModuleOptions()` for an example of how 
to do this).


http://reviews.llvm.org/D15685



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


Re: [PATCH] D15664: Teaches clang about Exynos-M1

2015-12-21 Thread Christof Douma via cfe-commits
christof added a comment.

LGTM. But since this is my first review, I would like somebody else to sign off 
on this as well.


http://reviews.llvm.org/D15664



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


Re: [PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

2015-12-21 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Friendly ping.

I don't think this change makes APCS mode worse. As an alternative I could 
return to the variant that doesn't change anything for APCS case. Please let me 
know if APCS case must be resolved and TODO is not enough for committing this 
change.


http://reviews.llvm.org/D14980



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


Re: [PATCH] D14629: [analyzer] Configuration file for scan-build.

2015-12-21 Thread Антон Ярцев via cfe-commits
ayartsev added a comment.

Ping


http://reviews.llvm.org/D14629



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


[PATCH] D15691: [OpenCL] Improving OpenCL function pointer error checking to catch lone function designator

2015-12-21 Thread Neil Hickey via cfe-commits
neil.hickey created this revision.
neil.hickey added a reviewer: cfe-commits.

An undecorated function designator implies taking the address of a function, 
which is illegal in OpenCL. Implementing a check for this earlier to allow the 
error to be reported even in the presence of other more obvious errors.

http://reviews.llvm.org/D15691

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExpr.cpp
  test/SemaOpenCL/cond.cl
  test/SemaOpenCL/func_ptr.cl

Index: test/SemaOpenCL/func_ptr.cl
===
--- test/SemaOpenCL/func_ptr.cl
+++ test/SemaOpenCL/func_ptr.cl
@@ -11,6 +11,9 @@
   foo((void*)foo); // expected-error{{taking address of function is not 
allowed}}
   foo(); // expected-error{{taking address of function is not allowed}}
 
+  // initializing an array with the address of functions is an error
+  void* vptrarr[2] = {foo, }; // expected-error{{taking address of 
function is not allowed}} expected-error{{taking address of function is not 
allowed}}
+
   // just calling a function is correct
   foo(0);
 }
Index: test/SemaOpenCL/cond.cl
===
--- test/SemaOpenCL/cond.cl
+++ test/SemaOpenCL/cond.cl
@@ -128,5 +128,5 @@
 
 unsigned int ntest12(int2 C)
 {
-  return (unsigned int)(C ? foo1 : foo2); // expected-error {{taking address 
of function is not allowed}}
+  return (unsigned int)(C ? foo1 : foo2); // expected-error {{taking address 
of function is not allowed}} expected-error {{taking address of function is not 
allowed}}
 }
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1334,8 +1334,23 @@
 return ExprError();
   }
 
+  // check to see whether Res is a function designator only. If it is and we
+  // are compiling for OpenCL, we need to return an error as this implies
+  // that the address of the function is being taken, which is illegal in CL
+
   // These can be followed by postfix-expr pieces.
-  return ParsePostfixExpressionSuffix(Res);
+  Res = ParsePostfixExpressionSuffix(Res);
+  Expr *PostfixExpr = Res.get();
+  if (PostfixExpr) {
+QualType Ty = PostfixExpr->getType();
+if (!Ty.isNull() && Ty->isFunctionType() && getLangOpts().OpenCL) {
+  Diag(PostfixExpr->getExprLoc(),
+   diag::err_opencl_taking_function_address_parser);
+  return ExprError();
+}
+  }
+
+  return Res;
 }
 
 /// \brief Once the leading part of a postfix-expression is parsed, this
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -910,6 +910,10 @@
 def warn_pragma_unknown_extension : Warning<
   "unknown OpenCL extension %0 - ignoring">, InGroup;
 
+// OpenCL error
+def err_opencl_taking_function_address_parser : Error<
+  "taking address of function is not allowed">;
+
 // OpenMP support.
 def warn_pragma_omp_ignored : Warning<
   "unexpected '#pragma omp ...' in program">, InGroup, 
DefaultIgnore;


Index: test/SemaOpenCL/func_ptr.cl
===
--- test/SemaOpenCL/func_ptr.cl
+++ test/SemaOpenCL/func_ptr.cl
@@ -11,6 +11,9 @@
   foo((void*)foo); // expected-error{{taking address of function is not allowed}}
   foo(); // expected-error{{taking address of function is not allowed}}
 
+  // initializing an array with the address of functions is an error
+  void* vptrarr[2] = {foo, }; // expected-error{{taking address of function is not allowed}} expected-error{{taking address of function is not allowed}}
+
   // just calling a function is correct
   foo(0);
 }
Index: test/SemaOpenCL/cond.cl
===
--- test/SemaOpenCL/cond.cl
+++ test/SemaOpenCL/cond.cl
@@ -128,5 +128,5 @@
 
 unsigned int ntest12(int2 C)
 {
-  return (unsigned int)(C ? foo1 : foo2); // expected-error {{taking address of function is not allowed}}
+  return (unsigned int)(C ? foo1 : foo2); // expected-error {{taking address of function is not allowed}} expected-error {{taking address of function is not allowed}}
 }
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1334,8 +1334,23 @@
 return ExprError();
   }
 
+  // check to see whether Res is a function designator only. If it is and we
+  // are compiling for OpenCL, we need to return an error as this implies
+  // that the address of the function is being taken, which is illegal in CL
+
   // These can be followed by postfix-expr pieces.
-  return ParsePostfixExpressionSuffix(Res);
+  Res = ParsePostfixExpressionSuffix(Res);
+  Expr *PostfixExpr = Res.get();
+  if (PostfixExpr) {
+QualType Ty = PostfixExpr->getType();
+if 

Re: [PATCH] D15664: Teaches clang about Exynos-M1

2015-12-21 Thread Tim Northover via cfe-commits
t.p.northover added a subscriber: t.p.northover.
t.p.northover accepted this revision.
t.p.northover added a reviewer: t.p.northover.
t.p.northover added a comment.

Looks fine to me too. Thanks!

Tim.


http://reviews.llvm.org/D15664



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


r256170 - clang-format: Only consider the first #include that looks right to be

2015-12-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 21 11:28:24 2015
New Revision: 256170

URL: http://llvm.org/viewvc/llvm-project?rev=256170=rev
Log:
clang-format: Only consider the first #include that looks right to be
the main #include.

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=256170=256169=256170=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 21 11:28:24 2015
@@ -1816,6 +1816,7 @@ tooling::Replacements sortIncludes(const
   FileName.endswith(".mm");
   StringRef FileStem = llvm::sys::path::stem(FileName);
   bool FirstIncludeBlock = true;
+  bool MainIncludeFound = false;
 
   // Create pre-compiled regular expressions for the #include categories.
   SmallVector CategoryRegexs;
@@ -1845,12 +1846,14 @@ tooling::Replacements sortIncludes(const
 break;
   }
 }
-if (IsSource && Category > 0 && FirstIncludeBlock &&
-IncludeName.startswith("\"")) {
+if (IsSource && !MainIncludeFound && Category > 0 &&
+FirstIncludeBlock && IncludeName.startswith("\"")) {
   StringRef HeaderStem =
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
-  if (FileStem.startswith(HeaderStem))
+  if (FileStem.startswith(HeaderStem)) {
 Category = 0;
+MainIncludeFound = true;
+  }
 }
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});
   } else if (!IncludesInBlock.empty()) {

Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=256170=256169=256170=diff
==
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original)
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Mon Dec 21 11:28:24 2015
@@ -204,6 +204,17 @@ TEST_F(SortIncludesTest, LeavesMainHeade
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
  "a.cc"));
+
+  // Only recognize the first #include with a matching basename as main 
include.
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n"
+"#include \"llvm/a.h\"\n",
+sort("#include \"b.h\"\n"
+ "#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"llvm/a.h\"\n",
+ "a.cc"));
 }
 
 TEST_F(SortIncludesTest, NegativePriorities) {


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