r355333 - Order File Instrumentation: add clang support for -forder-file-instrumentation

2019-03-04 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Mar  4 12:30:30 2019
New Revision: 355333

URL: http://llvm.org/viewvc/llvm-project?rev=355333&view=rev
Log:
Order File Instrumentation: add clang support for -forder-file-instrumentation

When -forder-file-instrumentation is on, we pass llvm flag to enable the order 
file instrumentation pass.

https://reviews.llvm.org/D58751


Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=355333&r1=355332&r2=355333&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Mar  4 12:30:30 2019
@@ -775,6 +775,9 @@ def fprofile_filter_files_EQ : Joined<["
 def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Instrument only functions from files where names don't match all 
the regexes separated by a semi-colon">;
+def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
+Group, Flags<[CC1Option, CoreOption]>,
+HelpText<"Generate instrumented code to collect order file into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;
 
 def faddrsig : Flag<["-"], "faddrsig">, Group, Flags<[CoreOption, 
CC1Option]>,
   HelpText<"Emit an address-significance table">;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=355333&r1=355332&r2=355333&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Mar  4 12:30:30 2019
@@ -409,7 +409,8 @@ bool ToolChain::needsProfileRT(const Arg
   Args.hasArg(options::OPT_fcs_profile_generate_EQ) ||
   Args.hasArg(options::OPT_fprofile_instr_generate) ||
   Args.hasArg(options::OPT_fprofile_instr_generate_EQ) ||
-  Args.hasArg(options::OPT_fcreate_profile))
+  Args.hasArg(options::OPT_fcreate_profile) ||
+  Args.hasArg(options::OPT_forder_file_instrumentation)) 
 return true;
 
   return false;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=355333&r1=355332&r2=355333&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Mar  4 12:30:30 2019
@@ -5337,6 +5337,17 @@ void Clang::ConstructJob(Compilation &C,
 }
   }
 
+  if (Args.hasArg(options::OPT_forder_file_instrumentation)) {
+ CmdArgs.push_back("-forder-file-instrumentation");
+ // Enable order file instrumentation when ThinLTO is not on. When ThinLTO 
is
+ // on, we need to pass these flags as linker flags and that will be 
handled
+ // outside of the compiler.
+ if (!D.isUsingLTO()) {
+   CmdArgs.push_back("-mllvm");
+   CmdArgs.push_back("-enable-order-file-instrumentation");
+ }
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
options::OPT_fno_force_enable_int128)) {
 if (A->getOption().matches(options::OPT_fforce_enable_int128))

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=355333&r1=355332&r2=355333&view=diff
==
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Mon Mar  4 12:30:30 2019
@@ -121,6 +121,8 @@
 // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | 
FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
 // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping 
-fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE 
%s
 // RUN: %clang -### -S -fprofile-remapping-file foo/bar.txt %s 2>&1 | 
FileCheck -check-prefix=CHECK-PROFILE-REMAP %s
+// RUN: %clang -### -S -forder-file-instrumentation %s 2>&1 | FileCheck 
-check-prefix=CHECK-ORDERFILE-INSTR %s
+// RUN: %clang -### -flto -forder-file-instrumentation %s 2>&1 | FileCheck 
-check-prefix=CHECK-ORDERFILE-INSTR-LTO %s
 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
 // CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm"
 // CHECK-PROFILE-GENERATE-DIR: 
"-fprofile-instrument-path=/some/dir{{/|}}{{.*}}"
@@ -132,6 +134,10 @@
 // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with 
'-fprofile-instr-generate'
 // CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping"
 // CHECK-PROFILE-REMAP: "-fp

r283145 - ObjectiveC: fix a seg fault when deserialing redeclaration of ObjCMethodDecl.

2016-10-03 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Oct  3 16:26:46 2016
New Revision: 283145

URL: http://llvm.org/viewvc/llvm-project?rev=283145&view=rev
Log:
ObjectiveC: fix a seg fault when deserialing redeclaration of ObjCMethodDecl.

The deserialization of redeclartion can cause seg fault since getCanonicalDecl
of the redeclaration returns the lookup result on the ObjCContainerDecl,
which can be null if FindExternalVisibleDeclsByName is not done updating
the lookup results.

The fix is to return the redeclaration itself as the canonical decl. Note that
the handling for redeclaration of ObjCMethodDecl is not in line with other
redeclarables.

rdar://28488466

Added:
cfe/trunk/test/Modules/Inputs/objc-method-redecl.h
cfe/trunk/test/Modules/objc-method-redecl.m
Modified:
cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=283145&r1=283144&r2=283145&view=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Mon Oct  3 16:26:46 2016
@@ -897,9 +897,13 @@ ObjCMethodDecl *ObjCMethodDecl::getCanon
 return MD;
   }
 
-  if (isRedeclaration())
-return cast(CtxD)->getMethod(getSelector(),
-isInstanceMethod());
+  if (isRedeclaration()) {
+// It is possible that we have not done deserializing the ObjCMethod yet.
+ObjCMethodDecl *MD =
+cast(CtxD)->getMethod(getSelector(),
+ isInstanceMethod());
+return MD ? MD : this;
+  }
 
   return this;
 }

Added: cfe/trunk/test/Modules/Inputs/objc-method-redecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-method-redecl.h?rev=283145&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-method-redecl.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-method-redecl.h Mon Oct  3 16:26:46 2016
@@ -0,0 +1,4 @@
+@interface T
+- (void)test;
+- (void)test;
+@end

Added: cfe/trunk/test/Modules/objc-method-redecl.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-method-redecl.m?rev=283145&view=auto
==
--- cfe/trunk/test/Modules/objc-method-redecl.m (added)
+++ cfe/trunk/test/Modules/objc-method-redecl.m Mon Oct  3 16:26:46 2016
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c-header 
-emit-pch %S/Inputs/objc-method-redecl.h -o %t.pch -Wno-objc-root-class
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c 
-include-pch %t.pch %s -verify -Wno-objc-root-class
+// expected-no-diagnostics
+
+@implementation T
+- (void)test {
+}
+@end


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


[PATCH] D25436: [CodeCompletion] Improve completion for properties declared in Objective-C protocols

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

Thanks for working on this!
Manman




Comment at: lib/Sema/SemaCodeComplete.cpp:3723
 }
   } else if (!IsArrow && BaseType->getAsObjCInterfacePointerType()) {
 // Objective-C property reference.

I feel like the added logic belongs to here :] Both handle property reference.

The clause here handles ObjCObjectPointerType that is based on an 
ObjCInterfaceType. We need to handle the case where the base type is "id".

What do you think?



Comment at: lib/Sema/SemaCodeComplete.cpp:3756
 }
+  } else if (const ObjCObjectPointerType *ObjCPtr =
+ BaseType->getAs()) {

Can we use "auto" here?


Repository:
  rL LLVM

https://reviews.llvm.org/D25436



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


[PATCH] D25283: AvailabilityAttrs: Refactor context checking when diagnosing an availability violation

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

This is a nice cleanup!

Manman




Comment at: lib/Sema/SemaDeclAttr.cpp:6348
+
+  auto IsContextGreater = [&](const Decl *C) {
+if (K == AR_NotYetIntroduced) {

Can you add a comment for the lambda?



Comment at: lib/Sema/SemaExpr.cpp:179
-  if (const DeclContext *DC = S.getCurObjCLexicalContext())
-ContextVersion = S.getVersionForDecl(cast(DC));
-

I don't quite get why we can remove the above logic (i.e why we can avoid 
passing ContextVersion when diagnosing the availability). Is it because we move 
the logic to DoEmitAvailabilityWarning?


https://reviews.llvm.org/D25283



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


[PATCH] D25284: AvailabilityAttrs: Delay partial availability diagnostics

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

Nice cleanup! Thanks for working on this,

Manman




Comment at: include/clang/Sema/DelayedDiagnostic.h:232
   union {
 /// Deprecation
 struct DD DeprecationData;

Can you update this comment now we have generalized this to handle all delayed 
availability checks?


https://reviews.llvm.org/D25284



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


[PATCH] D25436: [CodeCompletion] Improve completion for properties declared in Objective-C protocols

2016-10-11 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D25436



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


r283943 - Module: for ObjectiveC, be consistent when checking hidden decls.

2016-10-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Oct 11 16:18:20 2016
New Revision: 283943

URL: http://llvm.org/viewvc/llvm-project?rev=283943&view=rev
Log:
Module: for ObjectiveC, be consistent when checking hidden decls.

In MatchAllMethodDeclarations, when checking a hidden decl, be sure
to allow hidden when searching for methods.

rdar://28699972

Added:
cfe/trunk/test/Modules/Inputs/objc-hidden/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/objc-hidden/System/
cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h
cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map
cfe/trunk/test/Modules/objc-hidden.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=283943&r1=283942&r2=283943&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Oct 11 16:18:20 2016
@@ -2741,7 +2741,7 @@ void Sema::MatchAllMethodDeclarations(co
 } else {
   ObjCMethodDecl *ImpMethodDecl =
 IMPDecl->getInstanceMethod(I->getSelector());
-  assert(CDecl->getInstanceMethod(I->getSelector()) &&
+  assert(CDecl->getInstanceMethod(I->getSelector(), true/*AllowHidden*/) &&
  "Expected to find the method through lookup as well");
   // ImpMethodDecl may be null as in a @dynamic property.
   if (ImpMethodDecl) {
@@ -2767,7 +2767,7 @@ void Sema::MatchAllMethodDeclarations(co
 } else {
   ObjCMethodDecl *ImpMethodDecl =
 IMPDecl->getClassMethod(I->getSelector());
-  assert(CDecl->getClassMethod(I->getSelector()) &&
+  assert(CDecl->getClassMethod(I->getSelector(), true/*AllowHidden*/) &&
  "Expected to find the method through lookup as well");
   // ImpMethodDecl may be null as in a @dynamic property.
   if (ImpMethodDecl) {

Added: 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h?rev=283943&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
 Tue Oct 11 16:18:20 2016
@@ -0,0 +1,7 @@
+#include 
+
+__attribute__((availability(macosx,introduced=1066.0)))  
__attribute__((availability(ios,introduced=1066.0)))
+@interface UnavailableObjCClass : NSObject
+- (void)someMethod;
+@end
+

Added: 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap?rev=283943&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
 Tue Oct 11 16:18:20 2016
@@ -0,0 +1,5 @@
+framework module FakeUnavailableObjCFramework {
+  umbrella header "FakeUnavailableObjCFramework.h"
+  // Do not export to test hidden decls.
+  // export *
+}

Added: cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h?rev=283943&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h Tue Oct 11 16:18:20 
2016
@@ -0,0 +1,5 @@
+@protocol NSObject
+@property (readonly) int hash;
+@end
+@interface NSObject 
+@end

Added: cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map?rev=283943&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map (added)
+++ cf

[PATCH] D25519: [CodeCompletion] Refactor: Extract two Objective-C block formatting related functions from FormatFunctionParameter

2016-10-12 Thread Manman Ren via cfe-commits
manmanren added a comment.

Cheers,
Manman




Comment at: lib/Sema/SemaCodeComplete.cpp:2165
 
+static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo,
+ FunctionTypeLoc &Block,

Please add comments for the helper function.



Comment at: lib/Sema/SemaCodeComplete.cpp:2279
+static std::string
+formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl 
*BlockDecl,
+   FunctionTypeLoc &Block, FunctionProtoTypeLoc 
&BlockProto,

Comments here as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D25519



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


r284142 - Module: emit initializers for C/ObjC after r276159.

2016-10-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Oct 13 13:42:14 2016
New Revision: 284142

URL: http://llvm.org/viewvc/llvm-project?rev=284142&view=rev
Log:
Module: emit initializers for C/ObjC after r276159.

In r276159, we started to defer emitting initializers for VarDecls, but
forgot to add the initializers for non-C++ language.

rdar://28740482

Added:
cfe/trunk/test/Modules/Inputs/objc-initializer/
cfe/trunk/test/Modules/Inputs/objc-initializer/X.h
cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
cfe/trunk/test/Modules/objc-initializer.m
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284142&r1=284141&r2=284142&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 13 13:42:14 2016
@@ -10511,7 +10511,13 @@ void Sema::CheckCompleteVariableDeclarat
   }
 
   // All the following checks are C++ only.
-  if (!getLangOpts().CPlusPlus) return;
+  if (!getLangOpts().CPlusPlus) {
+  // If this variable must be emitted, add it as an initializer for the
+  // current module.
+ if (Context.DeclMustBeEmitted(var) && !ModuleScopes.empty())
+   Context.addModuleInitializer(ModuleScopes.back().Module, var);
+ return;
+  }
 
   if (auto *DD = dyn_cast(var))
 CheckCompleteDecompositionDeclaration(DD);

Added: cfe/trunk/test/Modules/Inputs/objc-initializer/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-initializer/X.h?rev=284142&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-initializer/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-initializer/X.h Thu Oct 13 13:42:14 2016
@@ -0,0 +1,3 @@
+@interface NSString
+@end
+static const NSString * const kSimDeviceIOGetInterface = 
@"simdeviceio_get_interface";

Added: cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap?rev=284142&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap Thu Oct 13 
13:42:14 2016
@@ -0,0 +1,4 @@
+module X {
+  header "X.h"
+  export *
+}

Added: cfe/trunk/test/Modules/objc-initializer.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-initializer.m?rev=284142&view=auto
==
--- cfe/trunk/test/Modules/objc-initializer.m (added)
+++ cfe/trunk/test/Modules/objc-initializer.m Thu Oct 13 13:42:14 2016
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc | FileCheck %s
+// CHECK: kSimDeviceIOGetInterface = internal constant {{.*}} bitcast
+
+#import 
+void test2(const NSString*);
+void test() {
+  test2(kSimDeviceIOGetInterface);
+}


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


r284263 - Module: emit initializers in submodules when importing the parent module.

2016-10-14 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Oct 14 13:55:44 2016
New Revision: 284263

URL: http://llvm.org/viewvc/llvm-project?rev=284263&view=rev
Log:
Module: emit initializers in submodules when importing the parent module.

When importing the parent module, module initializers in submodules should
be emitted.

rdar://28740482

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
cfe/trunk/test/Modules/objc-initializer.m

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Oct 14 13:55:44 2016
@@ -3951,9 +3951,33 @@ void CodeGenModule::EmitTopLevelDecl(Dec
 DI->EmitImportDecl(*Import);
 }
 
-// Emit the module initializers.
-for (auto *D : Context.getModuleInitializers(Import->getImportedModule()))
-  EmitTopLevelDecl(D);
+// Find all of the submodules and emit the module initializers.
+llvm::SmallPtrSet Visited;
+SmallVector Stack;
+Visited.insert(Import->getImportedModule());
+Stack.push_back(Import->getImportedModule());
+
+while (!Stack.empty()) {
+  clang::Module *Mod = Stack.pop_back_val();
+  if (!EmittedModuleInitializers.insert(Mod).second)
+continue;
+
+  for (auto *D : Context.getModuleInitializers(Mod))
+EmitTopLevelDecl(D);
+
+  // Visit the submodules of this module.
+  for (clang::Module::submodule_iterator Sub = Mod->submodule_begin(),
+ SubEnd = Mod->submodule_end();
+   Sub != SubEnd; ++Sub) {
+// Skip explicit children; they need to be explicitly imported to emit
+// the initializers.
+if ((*Sub)->IsExplicit)
+  continue;
+
+if (Visited.insert(*Sub).second)
+  Stack.push_back(*Sub);
+  }
+}
 break;
   }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Oct 14 13:55:44 2016
@@ -420,6 +420,10 @@ private:
   /// \brief The complete set of modules that has been imported.
   llvm::SetVector ImportedModules;
 
+  /// \brief The set of modules for which the module initializers
+  /// have been emitted.
+  llvm::SmallPtrSet EmittedModuleInitializers;
+
   /// \brief A vector of metadata strings.
   SmallVector LinkerOptionsMetadata;
 

Modified: cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap Fri Oct 14 
13:55:44 2016
@@ -1,4 +1,7 @@
 module X {
-  header "X.h"
+  module T {
+header "X.h"
+export *
+  }
   export *
 }

Modified: cfe/trunk/test/Modules/objc-initializer.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-initializer.m?rev=284263&r1=284262&r2=284263&view=diff
==
--- cfe/trunk/test/Modules/objc-initializer.m (original)
+++ cfe/trunk/test/Modules/objc-initializer.m Fri Oct 14 13:55:44 2016
@@ -1,8 +1,14 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc | FileCheck %s
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc -DIMPORT_TOP | 
FileCheck %s
 // CHECK: kSimDeviceIOGetInterface = internal constant {{.*}} bitcast
 
+#ifdef IMPORT_TOP
+@import X;
+#else
 #import 
+#endif
+
 void test2(const NSString*);
 void test() {
   test2(kSimDeviceIOGetInterface);


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


[PATCH] D25519: [CodeCompletion] Refactor: Extract two Objective-C block formatting related functions from FormatFunctionParameter

2016-10-14 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D25519



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


[clang] Support MemProf on darwin (PR #69640)

2023-10-19 Thread Manman Ren via cfe-commits

https://github.com/manman-ren created 
https://github.com/llvm/llvm-project/pull/69640

None

>From 86dc0db55bf6aa629639b1beac5c2cf5f39177ec Mon Sep 17 00:00:00 2001
From: Manman Ren 
Date: Tue, 10 Oct 2023 20:54:07 -0700
Subject: [PATCH 1/2] memprof support on Darwin

---
 clang/lib/Driver/ToolChains/Darwin.cpp|  3 +
 clang/test/Driver/darwin-memprof.c| 13 +
 .../cmake/Modules/AllSupportedArchDefs.cmake  |  2 +-
 compiler-rt/cmake/config-ix.cmake |  4 +-
 compiler-rt/lib/memprof/CMakeLists.txt| 30 +-
 compiler-rt/lib/memprof/memprof_allocator.cpp |  4 ++
 compiler-rt/lib/memprof/memprof_allocator.h   | 25 +---
 .../lib/memprof/memprof_interceptors.cpp  |  5 +-
 .../lib/memprof/memprof_interceptors.h|  6 ++
 compiler-rt/lib/memprof/memprof_linux.cpp |  5 +-
 compiler-rt/lib/memprof/memprof_mac.cpp   | 58 +++
 .../lib/memprof/memprof_malloc_linux.cpp  |  5 +-
 .../lib/memprof/memprof_malloc_mac.cpp| 37 
 .../lib/memprof/memprof_new_delete.cpp|  4 ++
 compiler-rt/lib/memprof/tests/CMakeLists.txt  |  2 +-
 compiler-rt/test/memprof/CMakeLists.txt   |  2 +-
 16 files changed, 184 insertions(+), 21 deletions(-)
 create mode 100644 clang/test/Driver/darwin-memprof.c
 create mode 100644 compiler-rt/lib/memprof/memprof_mac.cpp
 create mode 100644 compiler-rt/lib/memprof/memprof_malloc_mac.cpp

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 15b9889157b903c..e3a7a29e196e435 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1505,6 +1505,9 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList 
&Args,
  "Static sanitizer runtimes not supported");
   AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 }
+if (Sanitize.needsMemProfRt()) {
+  AddLinkSanitizerLibArgs(Args, CmdArgs, "memprof");
+}
 if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
   AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false);
 
diff --git a/clang/test/Driver/darwin-memprof.c 
b/clang/test/Driver/darwin-memprof.c
new file mode 100644
index 000..67746d88823b4a8
--- /dev/null
+++ b/clang/test/Driver/darwin-memprof.c
@@ -0,0 +1,13 @@
+// Test sanitizer link flags on Darwin.
+
+// RUN: %clang -### --target=x86_64-darwin \
+// RUN:   -stdlib=platform -fmemory-profile %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MEMPROF %s
+
+// CHECK-MEMPROF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MEMPROF-NOT: "-lstdc++"
+// CHECK-MEMPROF-NOT: "-lc++"
+// CHECK-MEMPROF: libclang_rt.memprof_osx_dynamic.dylib"
+// CHECK-MEMPROF: "-rpath" "@executable_path"
+// CHECK-MEMPROF: "-rpath" "{{.*}}lib{{.*}}darwin"
+
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 416777171d2ca75..e34f4d8804ddcb8 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -61,7 +61,7 @@ endif()
 set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}
 ${LOONGARCH64})
 set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
-set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
+set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64} ${ARM64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
 ${RISCV32} ${RISCV64} ${LOONGARCH64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a8e078f1ebc9888..ebf62b2fdb5e8ee 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -446,6 +446,7 @@ if(APPLE)
   endif()
 
   set(SANITIZER_COMMON_SUPPORTED_OS osx)
+  set(MEMPROF_SUPPORTED_OS osx)
   set(PROFILE_SUPPORTED_OS osx)
   set(TSAN_SUPPORTED_OS osx)
   set(XRAY_SUPPORTED_OS osx)
@@ -566,6 +567,7 @@ if(APPLE)
 message(STATUS "${platform} supported arches: 
${DARWIN_${platform}_ARCHS}")
 if(DARWIN_${platform}_ARCHS)
   list(APPEND SANITIZER_COMMON_SUPPORTED_OS ${platform})
+  list(APPEND MEMPROF_SUPPORTED_OS ${platform})
   list(APPEND PROFILE_SUPPORTED_OS ${platform})
 
   list_intersect(DARWIN_${platform}_TSAN_ARCHS 
DARWIN_${platform}_ARCHS ALL_TSAN_SUPPORTED_ARCH)
@@ -782,7 +784,7 @@ else()
 endif()
 
 if (COMPILER_RT_HAS_SANITIZER_COMMON AND MEMPROF_SUPPORTED_ARCH AND
-OS_NAME MATCHES "Linux")
+OS_NAME MATCHES "Darwin|Linux")
   set(COMPILER_RT_HAS_MEMPROF TRUE)
 else()
   set(COMPILER_RT_HAS_MEMPROF FALSE)
diff --git a/compiler-rt/lib/memprof/CMakeLists.txt 
b/compiler-rt/lib/memprof/CMakeLists.txt
index 3f55c2f5e075eed..b8bbcc55da11866 100644
--- a/compiler-rt/lib/memprof/CMakeLists.txt
+++ b/compiler-rt/lib/memprof/CMakeLists.txt
@@ -7,7 +7,9 @@ set(MEMPROF_SOURCES
   memprof_interceptors.cpp
   memprof_inte

[clang] Support VFE in thinLTO (PR #69735)

2023-10-20 Thread Manman Ren via cfe-commits

https://github.com/manman-ren created 
https://github.com/llvm/llvm-project/pull/69735

We add a run of GlobalDCEPass with ImportSummary. When ImportSummary is true, 
we remove virtual functions in vtables with VCallVisibility not Public. In this 
run, the regular GlobalDCEPass::AddVirtualFunctionDependencies will be 
bypassed, we will use ImportSummary to decide which virtual functions to remove.

Discussion points:
1> FuncsWithNonVtableRef: this is currently in ModuleSummaryIndex, does it
   make sense to be part of FunctionSummary?
   std::set FuncsWithNonVtableRef;
2> ComputeDependencies is copied from GlobalDCE to ModuleSummaryAnalysis, for 
the former,
   ConstantDependenciesCache is a member variable
3> match from summary to Function in IR
   Resolution is saved in std::set VFuncsToBeRemoved
   Use F->getGUID() or GlobalValue::getGUID(F->getName()) when searching in 
VFuncsToBeRemoved

TODO:
1> support hybrid Regular/ThinLTO
2> support legacy thinLTO backend (ThinLTOCodeGenerator)

>From 0468281436fc1e2e4e27f41af14347425b546644 Mon Sep 17 00:00:00 2001
From: Manman Ren 
Date: Thu, 5 Oct 2023 10:56:53 -0700
Subject: [PATCH] Support VFE in thinLTO

We add a run of GlobalDCEPass with ImportSummary. When ImportSummary is true, 
we remove
virtual functions in vtables with VCallVisibility not Public. In this run, the 
regular
GlobalDCEPass::AddVirtualFunctionDependencies will be bypassed, we will use
ImportSummary to decide which virtual functions to remove.

Discussion points:
1> FuncsWithNonVtableRef: this is currently in ModuleSummaryIndex, does it
   make sense to be part of FunctionSummary?
   std::set FuncsWithNonVtableRef;
2> ComputeDependencies is copied from GlobalDCE to ModuleSummaryAnalysis, for 
the former,
   ConstantDependenciesCache is a member variable
3> match from summary to Function in IR
   Resolution is saved in std::set VFuncsToBeRemoved
   Use F->getGUID() or GlobalValue::getGUID(F->getName()) when searching in 
VFuncsToBeRemoved

TODO:
1> support hybrid Regular/ThinLTO
2> support legacy thinLTO backend (ThinLTOCodeGenerator)
---
 clang/lib/Driver/ToolChains/Clang.cpp |   4 +-
 .../test/CodeGenCXX/type-metadata-memfun.cpp  |   2 +-
 clang/test/CodeGenCXX/vfe-thin.cpp| 102 +++
 .../Driver/virtual-function-elimination.cpp   |   3 +-
 llvm/include/llvm/AsmParser/LLParser.h|   1 +
 llvm/include/llvm/AsmParser/LLToken.h |   1 +
 llvm/include/llvm/Bitcode/LLVMBitCodes.h  |   1 +
 llvm/include/llvm/IR/ModuleSummaryIndex.h |  22 ++
 llvm/include/llvm/Transforms/IPO/GlobalDCE.h  |  15 +-
 llvm/lib/Analysis/ModuleSummaryAnalysis.cpp   |  65 -
 llvm/lib/AsmParser/LLParser.cpp   |  16 ++
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |   5 +
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp |  15 +
 llvm/lib/IR/AsmWriter.cpp |  13 +
 llvm/lib/LTO/LTO.cpp  |   8 +
 llvm/lib/Passes/PassBuilderPipelines.cpp  |   6 +
 llvm/lib/Transforms/IPO/GlobalDCE.cpp | 261 +-
 17 files changed, 531 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/vfe-thin.cpp

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c74f6ff447261dc..d59eb98eb2777e1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7378,10 +7378,10 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (VirtualFunctionElimination) {
 // VFE requires full LTO (currently, this might be relaxed to allow ThinLTO
 // in the future).
-if (LTOMode != LTOK_Full)
+if (LTOMode != LTOK_Full && LTOMode != LTOK_Thin)
   D.Diag(diag::err_drv_argument_only_allowed_with)
   << "-fvirtual-function-elimination"
-  << "-flto=full";
+  << "-flto";
 
 CmdArgs.push_back("-fvirtual-function-elimination");
   }
diff --git a/clang/test/CodeGenCXX/type-metadata-memfun.cpp 
b/clang/test/CodeGenCXX/type-metadata-memfun.cpp
index 764b1a3b72ba9ed..21b7dd6b36ac444 100644
--- a/clang/test/CodeGenCXX/type-metadata-memfun.cpp
+++ b/clang/test/CodeGenCXX/type-metadata-memfun.cpp
@@ -18,7 +18,7 @@ struct [[clang::lto_visibility_public]] S2 {
 S1::S1() {}
 S1::~S1() {}
 void S1::vf() {}
-// CHECK: define hidden void @_ZN2S11fEv{{.*}} !type [[S2F:![0-9]+]]
+// CHECK: define hidden void @_ZN2S11fEv{{.*}} !type [[S2F:![0-9]+]] foo
 void S1::f() {
   fdecl();
 }
diff --git a/clang/test/CodeGenCXX/vfe-thin.cpp 
b/clang/test/CodeGenCXX/vfe-thin.cpp
new file mode 100644
index 000..ef3bfa1739c11be
--- /dev/null
+++ b/clang/test/CodeGenCXX/vfe-thin.cpp
@@ -0,0 +1,102 @@
+// REQUIRES: system-darwin
+// RUN: rm -rf %t_devirt && mkdir %t_devirt
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+
+// TODO: separate this to frontend and backend tests
+// clang cc1 doesn't enable type metadata
+// RUN: %clang -flto=thin -target arm64-apple-ios16 -emit-llvm -c 
-fwhole-progra

[clang] Support VFE in thinLTO (PR #69735)

2023-10-20 Thread Manman Ren via cfe-commits

https://github.com/manman-ren updated 
https://github.com/llvm/llvm-project/pull/69735

>From 1adce63e663203f858de86cfa231527ee2284505 Mon Sep 17 00:00:00 2001
From: Manman Ren 
Date: Thu, 5 Oct 2023 10:56:53 -0700
Subject: [PATCH] Support VFE in thinLTO

We add a run of GlobalDCEPass with ImportSummary. When ImportSummary is true, 
we remove
virtual functions in vtables with VCallVisibility not Public. In this run, the 
regular
GlobalDCEPass::AddVirtualFunctionDependencies will be bypassed, we will use
ImportSummary to decide which virtual functions to remove.

Discussion points:
1> FuncsWithNonVtableRef: this is currently in ModuleSummaryIndex, does it
   make sense to be part of FunctionSummary?
   std::set FuncsWithNonVtableRef;
2> ComputeDependencies is copied from GlobalDCE to ModuleSummaryAnalysis, for 
the former,
   ConstantDependenciesCache is a member variable
3> match from summary to Function in IR
   Resolution is saved in std::set VFuncsToBeRemoved
   Use F->getGUID() or GlobalValue::getGUID(F->getName()) when searching in 
VFuncsToBeRemoved

TODO:
1> support hybrid Regular/ThinLTO
2> support legacy thinLTO backend (ThinLTOCodeGenerator)
---
 clang/lib/Driver/ToolChains/Clang.cpp |   4 +-
 clang/test/CodeGenCXX/vfe-thin.cpp| 123 +
 .../Driver/virtual-function-elimination.cpp   |   3 +-
 llvm/include/llvm/AsmParser/LLParser.h|   1 +
 llvm/include/llvm/AsmParser/LLToken.h |   1 +
 llvm/include/llvm/Bitcode/LLVMBitCodes.h  |   1 +
 llvm/include/llvm/IR/ModuleSummaryIndex.h |  22 ++
 llvm/include/llvm/Transforms/IPO/GlobalDCE.h  |  15 +-
 llvm/lib/Analysis/ModuleSummaryAnalysis.cpp   |  65 -
 llvm/lib/AsmParser/LLParser.cpp   |  16 ++
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |   5 +
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp |  15 +
 llvm/lib/IR/AsmWriter.cpp |  13 +
 llvm/lib/LTO/LTO.cpp  |   8 +
 llvm/lib/Passes/PassBuilderPipelines.cpp  |   6 +
 llvm/lib/Transforms/IPO/GlobalDCE.cpp | 261 +-
 16 files changed, 551 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/vfe-thin.cpp

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c74f6ff447261dc..d59eb98eb2777e1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7378,10 +7378,10 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (VirtualFunctionElimination) {
 // VFE requires full LTO (currently, this might be relaxed to allow ThinLTO
 // in the future).
-if (LTOMode != LTOK_Full)
+if (LTOMode != LTOK_Full && LTOMode != LTOK_Thin)
   D.Diag(diag::err_drv_argument_only_allowed_with)
   << "-fvirtual-function-elimination"
-  << "-flto=full";
+  << "-flto";
 
 CmdArgs.push_back("-fvirtual-function-elimination");
   }
diff --git a/clang/test/CodeGenCXX/vfe-thin.cpp 
b/clang/test/CodeGenCXX/vfe-thin.cpp
new file mode 100644
index 000..b05d196060353c1
--- /dev/null
+++ b/clang/test/CodeGenCXX/vfe-thin.cpp
@@ -0,0 +1,123 @@
+// REQUIRES: system-darwin
+// RUN: rm -rf %t_devirt && mkdir %t_devirt
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+
+// RUN: %clang -flto=thin -target arm64-apple-ios16 -emit-llvm -c 
-fwhole-program-vtables -fvirtual-function-elimination -mllvm 
-enable-vfe-summary -o %t.main.bc %t.dir/vfe-main.cpp
+// RUN: llvm-dis %t.main.bc -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang -flto=thin -target arm64-apple-ios16 -emit-llvm -c 
-fwhole-program-vtables -fvirtual-function-elimination -mllvm 
-enable-vfe-summary -o %t.input.bc %t.dir/vfe-input.cpp
+// RUN: llvm-dis %t.input.bc -o - | FileCheck %s --check-prefix=INPUT
+
+// RUN: llvm-lto2 run %t.main.bc %t.input.bc -save-temps 
-enable-vfe-on-thinlto -o %t.out \
+// RUN:   -r=%t.main.bc,__Z6test_1P1A,pl \
+// RUN:   -r=%t.main.bc,__Z4testv,pl \
+// RUN:   -r=%t.main.bc,__Znwm, \
+// RUN:   -r=%t.main.bc,__ZN1AC1Ev,pl \
+// RUN:   -r=%t.main.bc,___gxx_personality_v0, \
+// RUN:   -r=%t.main.bc,__ZN1AC2Ev,pl \
+// RUN:   -r=%t.main.bc,__ZN1BC2Ev,pl \
+// RUN:   -r=%t.main.bc,__ZN1BC1Ev,pl \
+// RUN:   -r=%t.main.bc,__ZN1A3fooEv,pl \
+// RUN:   -r=%t.main.bc,__ZN1A3barEv,pl \
+// RUN:   -r=%t.main.bc,__Z6test_2P1B,pl \
+// RUN:   -r=%t.main.bc,_main,plx \
+// RUN:   -r=%t.main.bc,__ZdlPv \
+// RUN:   -r=%t.main.bc,__ZTV1A,pl \
+// RUN:   -r=%t.main.bc,__ZTV1B, \
+// RUN:   -r=%t.main.bc,__ZTVN10__cxxabiv117__class_type_infoE, \
+// RUN:   -r=%t.main.bc,__ZTS1A,pl \
+// RUN:   -r=%t.main.bc,__ZTI1A,pl \
+// RUN:   -r=%t.input.bc,__ZN1CC2Ev,pl \
+// RUN:   -r=%t.input.bc,__ZN1CC1Ev,pl \
+// RUN:   -r=%t.input.bc,__Z6test_3P1C,pl \
+// RUN:   -r=%t.input.bc,__Z6test_4P1C,pl \
+// RUN:   -r=%t.input.bc,__Z6test_5P1CMS_FvvE,pl \
+// RUN:   -r=%t.input.bc,__ZTV1C,
+
+// RUN: llvm-dis %t.out.1.0.preopt.bc -o - | FileCheck %s 
--check-pr

[clang] Support MemProf on darwin (PR #69640)

2023-10-24 Thread Manman Ren via cfe-commits

https://github.com/manman-ren edited 
https://github.com/llvm/llvm-project/pull/69640
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Port Swift's merge function pass to llvm: merging functions that differ in constants (PR #68235)

2023-10-17 Thread Manman Ren via cfe-commits

https://github.com/manman-ren updated 
https://github.com/llvm/llvm-project/pull/68235

>From 7e422cecbd5fc28fb0ec699b702d6bccf321f93f Mon Sep 17 00:00:00 2001
From: Manman Ren 
Date: Mon, 2 Oct 2023 11:16:58 -0700
Subject: [PATCH] Preliminary patch for merging functions that differ in
 constants

---
 .../IPO/MergeFunctionsIgnoringConst.h |   34 +
 .../Transforms/Utils/FunctionComparator.h |1 +
 .../Utils/FunctionComparatorIgnoringConst.h   |   58 +
 .../Utils/FunctionHashIgnoringConst.h |   79 +
 .../Utils/MergeFunctionsIgnoringConst.h   |   29 +
 llvm/lib/Passes/PassBuilder.cpp   |1 +
 llvm/lib/Passes/PassBuilderPipelines.cpp  |   11 +
 llvm/lib/Passes/PassRegistry.def  |1 +
 llvm/lib/Transforms/IPO/CMakeLists.txt|1 +
 .../IPO/MergeFunctionsIgnoringConst.cpp   | 1430 +
 llvm/lib/Transforms/Utils/CMakeLists.txt  |2 +
 .../Utils/FunctionComparatorIgnoringConst.cpp |  107 ++
 .../Utils/FunctionHashIgnoringConst.cpp   |  620 +++
 .../unittests/Transforms/Utils/CMakeLists.txt |1 +
 .../Utils/FunctionHashIgnoringConstTest.cpp   |  120 ++
 15 files changed, 2495 insertions(+)
 create mode 100644 
llvm/include/llvm/Transforms/IPO/MergeFunctionsIgnoringConst.h
 create mode 100644 
llvm/include/llvm/Transforms/Utils/FunctionComparatorIgnoringConst.h
 create mode 100644 
llvm/include/llvm/Transforms/Utils/FunctionHashIgnoringConst.h
 create mode 100644 
llvm/include/llvm/Transforms/Utils/MergeFunctionsIgnoringConst.h
 create mode 100644 llvm/lib/Transforms/IPO/MergeFunctionsIgnoringConst.cpp
 create mode 100644 
llvm/lib/Transforms/Utils/FunctionComparatorIgnoringConst.cpp
 create mode 100644 llvm/lib/Transforms/Utils/FunctionHashIgnoringConst.cpp
 create mode 100644 
llvm/unittests/Transforms/Utils/FunctionHashIgnoringConstTest.cpp

diff --git a/llvm/include/llvm/Transforms/IPO/MergeFunctionsIgnoringConst.h 
b/llvm/include/llvm/Transforms/IPO/MergeFunctionsIgnoringConst.h
new file mode 100644
index 000..f9d55cc40873adc
--- /dev/null
+++ b/llvm/include/llvm/Transforms/IPO/MergeFunctionsIgnoringConst.h
@@ -0,0 +1,34 @@
+//===- MergeFunctionsIgnoringConst.h - Merge Functions --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This pass transforms simple global variables that never have their address
+// taken.  If obviously true, it marks read/write globals as constant, deletes
+// variables only stored to, etc.
+//
+//===--===//
+
+#ifndef LLVM_TRANSFORMS_IPO_MERGEFUNCTIONSIGNORINGCONST_H
+#define LLVM_TRANSFORMS_IPO_MERGEFUNCTIONSIGNORINGCONST_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+class Module;
+
+/// Merge functions that differ by constants.
+class MergeFuncIgnoringConstPass
+: public PassInfoMixin {
+public:
+  MergeFuncIgnoringConstPass() {}
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_TRANSFORMS_IPO_MERGEFUNCTIONSIGNORINGCONST_H
diff --git a/llvm/include/llvm/Transforms/Utils/FunctionComparator.h 
b/llvm/include/llvm/Transforms/Utils/FunctionComparator.h
index c28f868039a1f7b..1a314b481c72c61 100644
--- a/llvm/include/llvm/Transforms/Utils/FunctionComparator.h
+++ b/llvm/include/llvm/Transforms/Utils/FunctionComparator.h
@@ -379,6 +379,7 @@ class FunctionComparator {
   /// But, we are still not able to compare operands of PHI nodes, since those
   /// could be operands from further BBs we didn't scan yet.
   /// So it's impossible to use dominance properties in general.
+protected:
   mutable DenseMap sn_mapL, sn_mapR;
 
   // The global state we will use
diff --git 
a/llvm/include/llvm/Transforms/Utils/FunctionComparatorIgnoringConst.h 
b/llvm/include/llvm/Transforms/Utils/FunctionComparatorIgnoringConst.h
new file mode 100644
index 000..a61e02fa41db762
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Utils/FunctionComparatorIgnoringConst.h
@@ -0,0 +1,58 @@
+//===- FunctionComparatorIgnoringConst.h - Function Comparator --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines the FunctionComparatorIgnoringConst class which is used by
+// the MergeFuncIgnoringConst pass for comparing functions.
+//
+//===--===//
+
+#ifndef LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATORIGNORINGCONST_H
+#define LLVM_TR

r291465 - PCH: fix a regression that reports a module is defined in both pch and pcm.

2017-01-09 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Jan  9 13:20:18 2017
New Revision: 291465

URL: http://llvm.org/viewvc/llvm-project?rev=291465&view=rev
Log:
PCH: fix a regression that reports a module is defined in both pch and pcm.

In r276159, we started to say that a module X is defined in a pch if we specify
-fmodule-name when building the pch. This caused a regression that reports
module X is defined in both pch and pcm if we generate the pch with
-fmodule-name=X and then in a separate clang invocation, we include the pch and
also import X.pcm.

This patch adds an option CompilingPCH similar to CompilingModule. When we use
-fmodule-name=X while building a pch, modular headers in X will be textually
included and the compiler knows that we are not building module X, so we don't
put module X in SUBMODULE_DEFINITION of the pch.

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

Added:
cfe/trunk/test/Modules/Inputs/pch-with-module-name/
cfe/trunk/test/Modules/Inputs/pch-with-module-name/A.h
cfe/trunk/test/Modules/Inputs/pch-with-module-name/C.h
cfe/trunk/test/Modules/Inputs/pch-with-module-name/C.m
cfe/trunk/test/Modules/Inputs/pch-with-module-name/D.h
cfe/trunk/test/Modules/Inputs/pch-with-module-name/module.modulemap
cfe/trunk/test/Modules/Inputs/pch-with-module-name/test.h
cfe/trunk/test/Modules/pch-with-module-name.m
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=291465&r1=291464&r2=291465&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Jan  9 13:20:18 2017
@@ -146,6 +146,7 @@ LANGOPT(Modules   , 1, 0, "modul
 COMPATIBLE_LANGOPT(ModulesTS  , 1, 0, "C++ Modules TS")
 BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 2, CMK_None,
 "compiling a module interface")
+BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")
 COMPATIBLE_LANGOPT(ModulesDeclUse, 1, 0, "require declaration of module 
uses")
 BENIGN_LANGOPT(ModulesSearchAll  , 1, 1, "searching even non-imported modules 
to find unresolved references")
 COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of 
module uses and all headers to be in modules")

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=291465&r1=291464&r2=291465&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Mon Jan  9 13:20:18 2017
@@ -88,6 +88,8 @@ public:
   static std::unique_ptr
   ComputeASTConsumerArguments(CompilerInstance &CI, StringRef InFile,
   std::string &Sysroot, std::string &OutputFile);
+
+  bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) 
override;
 };
 
 class GenerateModuleAction : public ASTFrontendAction {

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=291465&r1=291464&r2=291465&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Mon Jan  9 13:20:18 2017
@@ -127,6 +127,12 @@ GeneratePCHAction::ComputeASTConsumerArg
   return OS;
 }
 
+bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI,
+  StringRef Filename) {
+  CI.getLangOpts().CompilingPCH = true;
+  return true;
+}
+
 std::unique_ptr
 GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
 StringRef InFile) {

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=291465&r1=291464&r2=291465&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Jan  9 13:20:18 2017
@@ -1996,10 +1996,12 @@ void Preprocessor::HandleIncludeDirectiv
 
   // Ask HeaderInfo if we should enter this #include file.  If not, #including
   // this file will have no effect.
+  bool SkipHeader = false;
   if (ShouldEnter &&
   !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
  SuggestedModule.getModule())) {
 ShouldEnter = false;
+SkipHeader = true;
 if (Callbacks

r291628 - Module: Do not create Implicit ImportDecl for module X if we

2017-01-10 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Jan 10 18:48:19 2017
New Revision: 291628

URL: http://llvm.org/viewvc/llvm-project?rev=291628&view=rev
Log:
Module: Do not create Implicit ImportDecl for module X if we
 are building an implemenation of module X.

This fixes a regression caused by r280409.
rdar://problem/29930553

Added:
cfe/trunk/test/Modules/Inputs/module-impl-with-link/
cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h
cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap
cfe/trunk/test/Modules/module-impl-with-link.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=291628&r1=291627&r2=291628&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Jan 10 18:48:19 2017
@@ -1905,7 +1905,8 @@ public:
   /// \brief The parser has processed a module import translated from a
   /// #include or similar preprocessing directive.
   void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
-  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
+  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
+  bool NoImport);
 
   /// \brief The parsed has entered a submodule.
   void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod);

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=291628&r1=291627&r2=291628&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 10 18:48:19 2017
@@ -15652,10 +15652,11 @@ DeclResult Sema::ActOnModuleImport(Sourc
 
 void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
   checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext, true);
-  BuildModuleInclude(DirectiveLoc, Mod);
+  BuildModuleInclude(DirectiveLoc, Mod, false/*NoImport*/);
 }
 
-void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
+void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
+  bool NoImport) {
   // Determine whether we're in the #include buffer for a module. The #includes
   // in that buffer do not qualify as module imports; they're just an
   // implementation detail of us building the module.
@@ -15665,7 +15666,7 @@ void Sema::BuildModuleInclude(SourceLoca
   TUKind == TU_Module &&
   getSourceManager().isWrittenInMainFile(DirectiveLoc);
 
-  bool ShouldAddImport = !IsInModuleIncludes;
+  bool ShouldAddImport = !IsInModuleIncludes && !NoImport;
 
   // If this module import was due to an inclusion directive, create an
   // implicit import declaration to capture it in the AST.
@@ -15713,7 +15714,11 @@ void Sema::ActOnModuleEnd(SourceLocation
   assert(File != getSourceManager().getMainFileID() &&
  "end of submodule in main source file");
   SourceLocation DirectiveLoc = getSourceManager().getIncludeLoc(File);
-  BuildModuleInclude(DirectiveLoc, Mod);
+  // Do not create implicit ImportDecl if we are building the implementation
+  // of a module.
+  bool NoImport = Mod->getTopLevelModuleName() == getLangOpts().CurrentModule 
&&
+  !getLangOpts().isCompilingModule();
+  BuildModuleInclude(DirectiveLoc, Mod, NoImport);
 }
 
 void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,

Added: cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h?rev=291628&view=auto
==
--- cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h (added)
+++ cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h Tue Jan 10 
18:48:19 2017
@@ -0,0 +1 @@
+//empty

Added: cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap?rev=291628&view=auto
==
--- cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap Tue 
Jan 10 18:48:19 2017
@@ -0,0 +1,4 @@
+module Clib {
+  header "foo.h"
+  link "Clib"
+}

Added: cfe/trunk/test/Modules/module-impl-with-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-impl-with-link.c?rev=291628&view=auto
==
--- cfe/trunk/test/Modules/module-impl-with-link.c (added)
+++ cfe/trunk/test/Modules/module-impl-with-link.c Tue J

Re: r291628 - Module: Do not create Implicit ImportDecl for module X if we

2017-01-10 Thread Manman Ren via cfe-commits
On Tue, Jan 10, 2017 at 5:59 PM, Richard Smith 
wrote:

> On 10 January 2017 at 17:57, Richard Smith  wrote:
>
>> On 10 January 2017 at 16:48, Manman Ren via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: mren
>>> Date: Tue Jan 10 18:48:19 2017
>>> New Revision: 291628
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=291628&view=rev
>>> Log:
>>> Module: Do not create Implicit ImportDecl for module X if we
>>>  are building an implemenation of module X.
>>>
>>
>> Hmm. We do actually have an include mapping to a module header in this
>> case. Perhaps it would be better to create a faithful AST representation
>> and handle this in CodeGen instead -- we should not add any link flags when
>> an implementation TU of a module imports a header of that same module.
>>
>
> It's worth pointing out that the C++ modules TS allows a modular import of
> a module interface into an implementation unit of that module, so the
> current approach won't work for that case, but filtering these imports out
> in CodeGen would work.
>

Makes sense. I will commit a follow-up patch.

Manman

>
>
>> This fixes a regression caused by r280409.
>>> rdar://problem/29930553
>>>
>>> Added:
>>> cfe/trunk/test/Modules/Inputs/module-impl-with-link/
>>> cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h
>>> cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap
>>> cfe/trunk/test/Modules/module-impl-with-link.c
>>> Modified:
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Sema/Sema.h?rev=291628&r1=291627&r2=291628&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Jan 10 18:48:19 2017
>>> @@ -1905,7 +1905,8 @@ public:
>>>/// \brief The parser has processed a module import translated from a
>>>/// #include or similar preprocessing directive.
>>>void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
>>> -  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
>>> +  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
>>> +  bool NoImport);
>>>
>>>/// \brief The parsed has entered a submodule.
>>>void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaD
>>> ecl.cpp?rev=291628&r1=291627&r2=291628&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 10 18:48:19 2017
>>> @@ -15652,10 +15652,11 @@ DeclResult Sema::ActOnModuleImport(Sourc
>>>
>>>  void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module
>>> *Mod) {
>>>checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext, true);
>>> -  BuildModuleInclude(DirectiveLoc, Mod);
>>> +  BuildModuleInclude(DirectiveLoc, Mod, false/*NoImport*/);
>>>  }
>>>
>>> -void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module
>>> *Mod) {
>>> +void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
>>> +  bool NoImport) {
>>>// Determine whether we're in the #include buffer for a module. The
>>> #includes
>>>// in that buffer do not qualify as module imports; they're just an
>>>// implementation detail of us building the module.
>>> @@ -15665,7 +15666,7 @@ void Sema::BuildModuleInclude(SourceLoca
>>>TUKind == TU_Module &&
>>>getSourceManager().isWrittenInMainFile(DirectiveLoc);
>>>
>>> -  bool ShouldAddImport = !IsInModuleIncludes;
>>> +  bool ShouldAddImport = !IsInModuleIncludes && !NoImport;
>>>
>>>// If this module import was due to an inclusion directive, create an
>>>// implicit import declaration to capture it in the AST.
>>> @@ -15713,7 +15714,11 @@ void Sema::ActOnModuleEnd(SourceLocation
&g

r291688 - This reverts r291628. As suggested by Richard, we can simply

2017-01-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Jan 11 12:32:30 2017
New Revision: 291688

URL: http://llvm.org/viewvc/llvm-project?rev=291688&view=rev
Log:
This reverts r291628. As suggested by Richard, we can simply
filter out the implicilty imported modules at CodeGen instead of removing the
implicit ImportDecl when an implementation TU of a module imports a header of
that same module.

Removed:
cfe/trunk/test/Modules/Inputs/module-impl-with-link/
cfe/trunk/test/Modules/module-impl-with-link.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=291688&r1=291687&r2=291688&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 11 12:32:30 2017
@@ -1905,8 +1905,7 @@ public:
   /// \brief The parser has processed a module import translated from a
   /// #include or similar preprocessing directive.
   void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
-  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
-  bool NoImport);
+  void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
 
   /// \brief The parsed has entered a submodule.
   void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod);

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=291688&r1=291687&r2=291688&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan 11 12:32:30 2017
@@ -15652,11 +15652,10 @@ DeclResult Sema::ActOnModuleImport(Sourc
 
 void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
   checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext, true);
-  BuildModuleInclude(DirectiveLoc, Mod, false/*NoImport*/);
+  BuildModuleInclude(DirectiveLoc, Mod);
 }
 
-void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
-  bool NoImport) {
+void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
   // Determine whether we're in the #include buffer for a module. The #includes
   // in that buffer do not qualify as module imports; they're just an
   // implementation detail of us building the module.
@@ -15666,7 +15665,7 @@ void Sema::BuildModuleInclude(SourceLoca
   TUKind == TU_Module &&
   getSourceManager().isWrittenInMainFile(DirectiveLoc);
 
-  bool ShouldAddImport = !IsInModuleIncludes && !NoImport;
+  bool ShouldAddImport = !IsInModuleIncludes;
 
   // If this module import was due to an inclusion directive, create an
   // implicit import declaration to capture it in the AST.
@@ -15714,11 +15713,7 @@ void Sema::ActOnModuleEnd(SourceLocation
   assert(File != getSourceManager().getMainFileID() &&
  "end of submodule in main source file");
   SourceLocation DirectiveLoc = getSourceManager().getIncludeLoc(File);
-  // Do not create implicit ImportDecl if we are building the implementation
-  // of a module.
-  bool NoImport = Mod->getTopLevelModuleName() == getLangOpts().CurrentModule 
&&
-  !getLangOpts().isCompilingModule();
-  BuildModuleInclude(DirectiveLoc, Mod, NoImport);
+  BuildModuleInclude(DirectiveLoc, Mod);
 }
 
 void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,

Removed: cfe/trunk/test/Modules/module-impl-with-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-impl-with-link.c?rev=291687&view=auto
==
--- cfe/trunk/test/Modules/module-impl-with-link.c (original)
+++ cfe/trunk/test/Modules/module-impl-with-link.c (removed)
@@ -1,7 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps 
-fmodule-name=Clib %s -I %S/Inputs/module-impl-with-link -emit-llvm -o -
-#include "foo.h"
-// CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[LINK_OPTIONS:[0-9]+]]}
-// Make sure we don't generate linker option for module Clib since this TU is
-// an implementation of Clib.
-// CHECK: ![[LINK_OPTIONS]] = !{}


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


r291689 - Module: Do not add any link flags when an implementation TU of a module imports

2017-01-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Jan 11 12:47:38 2017
New Revision: 291689

URL: http://llvm.org/viewvc/llvm-project?rev=291689&view=rev
Log:
Module: Do not add any link flags when an implementation TU of a module imports
a header of that same module.

This fixes a regression caused by r280409.
rdar://problem/29930553

This is an updated version for r291628 (which was reverted in r291688).

Added:
cfe/trunk/test/Modules/Inputs/module-impl-with-link/
cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h
cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap
cfe/trunk/test/Modules/module-impl-with-link.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=291689&r1=291688&r2=291689&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Jan 11 12:47:38 2017
@@ -1243,9 +1243,15 @@ void CodeGenModule::EmitModuleLinkOption
   SmallVector Stack;
 
   // Seed the stack with imported modules.
-  for (Module *M : ImportedModules)
+  for (Module *M : ImportedModules) {
+// Do not add any link flags when an implementation TU of a module imports
+// a header of that same module.
+if (M->getTopLevelModuleName() == getLangOpts().CurrentModule &&
+!getLangOpts().isCompilingModule())
+  continue;
 if (Visited.insert(M).second)
   Stack.push_back(M);
+  }
 
   // Find all of the modules to import, making a little effort to prune
   // non-leaf modules.

Added: cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h?rev=291689&view=auto
==
--- cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h (added)
+++ cfe/trunk/test/Modules/Inputs/module-impl-with-link/foo.h Wed Jan 11 
12:47:38 2017
@@ -0,0 +1 @@
+//empty

Added: cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap?rev=291689&view=auto
==
--- cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/module-impl-with-link/module.modulemap Wed 
Jan 11 12:47:38 2017
@@ -0,0 +1,4 @@
+module Clib {
+  header "foo.h"
+  link "Clib"
+}

Added: cfe/trunk/test/Modules/module-impl-with-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-impl-with-link.c?rev=291689&view=auto
==
--- cfe/trunk/test/Modules/module-impl-with-link.c (added)
+++ cfe/trunk/test/Modules/module-impl-with-link.c Wed Jan 11 12:47:38 2017
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps 
-fmodule-name=Clib %s -I %S/Inputs/module-impl-with-link -emit-llvm -o -
+#include "foo.h"
+// CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[LINK_OPTIONS:[0-9]+]]}
+// Make sure we don't generate linker option for module Clib since this TU is
+// an implementation of Clib.
+// CHECK: ![[LINK_OPTIONS]] = !{}


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


r278742 - Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.

2016-08-15 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Aug 15 16:05:00 2016
New Revision: 278742

URL: http://llvm.org/viewvc/llvm-project?rev=278742&view=rev
Log:
Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.

For the following example:
typedef __attribute__((NSObject)) CGColorRef ColorAttrRef;
@property (strong, nullable) ColorAttrRef color;
The property type should be ObjC NSObject type and the compiler should not emit
error: property with 'retain (or strong)' attribute must be of object type

rdar://problem/27747154

Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaObjC/nsobject-attribute.m

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=278742&r1=278741&r2=278742&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Aug 15 16:05:00 2016
@@ -3686,10 +3686,18 @@ bool Type::isObjCARCImplicitlyUnretained
 }
 
 bool Type::isObjCNSObjectType() const {
-  if (const TypedefType *typedefType = dyn_cast(this))
-return typedefType->getDecl()->hasAttr();
-  return false;
+  const Type *cur = this;
+  while (true) {
+if (const TypedefType *typedefType = dyn_cast(cur))
+  return typedefType->getDecl()->hasAttr();
+
+// Single-step desugar until we run out of sugar.
+QualType next = cur->getLocallyUnqualifiedSingleStepDesugaredType();
+if (next.getTypePtr() == cur) return false;
+cur = next.getTypePtr();
+  }
 }
+
 bool Type::isObjCIndependentClassType() const {
   if (const TypedefType *typedefType = dyn_cast(this))
 return typedefType->getDecl()->hasAttr();

Modified: cfe/trunk/test/SemaObjC/nsobject-attribute.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute.m?rev=278742&r1=278741&r2=278742&view=diff
==
--- cfe/trunk/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute.m Mon Aug 15 16:05:00 2016
@@ -21,6 +21,8 @@ typedef struct CGColor * __attribute__((
 @property (nonatomic, retain) CGColorRefNoNSObject color;
 // rdar://problem/12197822
 @property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning
+//rdar://problem/27747154
+@property (strong, nullable) CGColorRefNoNSObject color2; // no-warning
 @end
 
 void setProperty(id self, id value)  {


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


Re: [PATCH] D23003: [ObjC Availability] Warn upon unguarded use of partially available declaration

2016-08-15 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.



> This is done so containers, such as `vector` can be used 
> safely provided `partially_available` is safe at the point of instantiation. 
> I think the way to improve this is in `Sema::getVersionForDecl()`. There we 
> could look at function and template parameters to determine the best base 
> version, then diagnose against it.


Let's fix the diagnostics for dependent type in a follow-up patch. And your 
suggestion above sounds reasonable to me.

Thanks for the work!
Manman


https://reviews.llvm.org/D23003



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


Re: [PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-08-15 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.
manmanren added a comment.

The fix looks reasonable to me.

Cheers,
Manman



Comment at: test/CodeGenObjCXX/encode.mm:231
@@ +230,3 @@
+struct S {
+  typedef T Ty;
+  Ty *t;

I wonder if we can further reduce the testing case. Is this necessary to cause 
the infinite recursion?


https://reviews.llvm.org/D22929



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


Re: [PATCH] D22794: [Sema] Propagate nullability when deducing type of auto

2016-08-15 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.


Comment at: lib/Sema/SemaDecl.cpp:9739
@@ +9738,3 @@
+  DeducedType = DeducedType.setNullability(
+  Init->getType()->getNullability(Context), Context);
+

Do we propagate other attributes for deduced types?


https://reviews.llvm.org/D22794



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


Re: [PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-08-16 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a reviewer: manmanren.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


https://reviews.llvm.org/D22929



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-16 Thread Manman Ren via cfe-commits
manmanren added a comment.

Richard,

Are you okay with the patch now?

Thanks,
Manman


https://reviews.llvm.org/D23125



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 68442.

https://reviews.llvm.org/D23125

Files:
  docs/Modules.rst
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/Module.h
  lib/Driver/Tools.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ModuleManager.cpp
  test/Driver/modules.m
  test/Modules/Inputs/prebuilt-module/a.h
  test/Modules/Inputs/prebuilt-module/module.modulemap
  test/Modules/prebuilt-module.m

Index: test/Modules/prebuilt-module.m
===
--- test/Modules/prebuilt-module.m
+++ test/Modules/prebuilt-module.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -fmodules -x objective-c -I %S/Inputs/prebuilt-module -triple %itanium_abi_triple -emit-module %S/Inputs/prebuilt-module/module.modulemap -fmodule-name=prebuilt -o %t/prebuilt.pcm
+// RUN: %clang_cc1 -fmodules -fprebuilt-module-path=%t/ -fdisable-module-hash %s -verify
+
+// expected-no-diagnostics
+@import prebuilt;
+int test() {
+  return a;
+}
Index: test/Modules/Inputs/prebuilt-module/module.modulemap
===
--- test/Modules/Inputs/prebuilt-module/module.modulemap
+++ test/Modules/Inputs/prebuilt-module/module.modulemap
@@ -0,0 +1 @@
+module prebuilt { header "a.h" }
Index: test/Modules/Inputs/prebuilt-module/a.h
===
--- test/Modules/Inputs/prebuilt-module/a.h
+++ test/Modules/Inputs/prebuilt-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -39,6 +39,13 @@
 // RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
 
+// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH_DEFAULT %s
+// MODULES_PREBUILT_PATH_DEFAULT-NOT: -fprebuilt-module-path
+
+// RUN: %clang -fmodules -fprebuilt-module-path=foo -fprebuilt-module-path=bar -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH %s
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=foo"
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=bar"
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -66,7 +66,7 @@
   // Look for the file entry. This only fails if the expected size or
   // modification time differ.
   const FileEntry *Entry;
-  if (Type == MK_ExplicitModule) {
+  if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
 // If we're not expecting to pull this file out of the module cache, it
 // might have a different mtime due to being moved across filesystems in
 // a distributed build. The size must still match, though. (As must the
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1384,7 +1384,7 @@
 // any other module's anonymous namespaces, so don't attach the anonymous
 // namespace at all.
 NamespaceDecl *Anon = cast(Reader.GetDecl(AnonNamespace));
-if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule)
+if (!F.isModule())
   D->setAnonymousNamespace(Anon);
   }
 }
@@ -3747,8 +3747,7 @@
   // Each module has its own anonymous namespace, which is disjoint from
   // any other module's anonymous namespaces, so don't attach the anonymous
   // namespace at all.
-  if (ModuleFile.Kind != MK_ImplicitModule &&
-  ModuleFile.Kind != MK_ExplicitModule) {
+  if (!ModuleFile.isModule()) {
 if (TranslationUnitDecl *TU = dyn_cast(D))
   TU->setAnonymousNamespace(Anon);
 else
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1312,8 +1312,7 @@
 SrcMgr::CharacteristicKind
   FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
 SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
-if (IncludeLoc.isInvalid() &&
-(F->Kind == MK_ImplicitModu

Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks,

Manman



Comment at: lib/Frontend/CompilerInstance.cpp:1502
@@ +1501,3 @@
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+if (!Module) {
+  getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)

Updated the patch to use error diagnostics instead of assertion.

<<<
It'd also be good to check that Module->ASTFile actually refers to the file 
that we found in the prebuilt module path, and not (say) to one of its 
transitive dependencies that ReadAST also loaded.

Did we already check this when creating the module in ASTReader?
  if (!ParentModule) {
if (const FileEntry *CurFile = CurrentModule->getASTFile()) {
  if (CurFile != F.File) {
...
  }
}

CurrentModule->setASTFile(F.File);
  }



https://reviews.llvm.org/D23125



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 68456.

https://reviews.llvm.org/D23125

Files:
  docs/Modules.rst
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/Module.h
  lib/Driver/Tools.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ModuleManager.cpp
  test/Driver/modules.m
  test/Modules/Inputs/prebuilt-module/a.h
  test/Modules/Inputs/prebuilt-module/module.modulemap
  test/Modules/prebuilt-module.m

Index: test/Modules/prebuilt-module.m
===
--- test/Modules/prebuilt-module.m
+++ test/Modules/prebuilt-module.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -fmodules -x objective-c -I %S/Inputs/prebuilt-module -triple %itanium_abi_triple -emit-module %S/Inputs/prebuilt-module/module.modulemap -fmodule-name=prebuilt -o %t/prebuilt.pcm
+// RUN: %clang_cc1 -fmodules -fprebuilt-module-path=%t/ -fdisable-module-hash %s -verify
+
+// expected-no-diagnostics
+@import prebuilt;
+int test() {
+  return a;
+}
Index: test/Modules/Inputs/prebuilt-module/module.modulemap
===
--- test/Modules/Inputs/prebuilt-module/module.modulemap
+++ test/Modules/Inputs/prebuilt-module/module.modulemap
@@ -0,0 +1 @@
+module prebuilt { header "a.h" }
Index: test/Modules/Inputs/prebuilt-module/a.h
===
--- test/Modules/Inputs/prebuilt-module/a.h
+++ test/Modules/Inputs/prebuilt-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -39,6 +39,13 @@
 // RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
 
+// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH_DEFAULT %s
+// MODULES_PREBUILT_PATH_DEFAULT-NOT: -fprebuilt-module-path
+
+// RUN: %clang -fmodules -fprebuilt-module-path=foo -fprebuilt-module-path=bar -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH %s
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=foo"
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=bar"
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -66,7 +66,7 @@
   // Look for the file entry. This only fails if the expected size or
   // modification time differ.
   const FileEntry *Entry;
-  if (Type == MK_ExplicitModule) {
+  if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
 // If we're not expecting to pull this file out of the module cache, it
 // might have a different mtime due to being moved across filesystems in
 // a distributed build. The size must still match, though. (As must the
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1384,7 +1384,7 @@
 // any other module's anonymous namespaces, so don't attach the anonymous
 // namespace at all.
 NamespaceDecl *Anon = cast(Reader.GetDecl(AnonNamespace));
-if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule)
+if (!F.isModule())
   D->setAnonymousNamespace(Anon);
   }
 }
@@ -3747,8 +3747,7 @@
   // Each module has its own anonymous namespace, which is disjoint from
   // any other module's anonymous namespaces, so don't attach the anonymous
   // namespace at all.
-  if (ModuleFile.Kind != MK_ImplicitModule &&
-  ModuleFile.Kind != MK_ExplicitModule) {
+  if (!ModuleFile.isModule()) {
 if (TranslationUnitDecl *TU = dyn_cast(D))
   TU->setAnonymousNamespace(Anon);
 else
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1312,8 +1312,7 @@
 SrcMgr::CharacteristicKind
   FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
 SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
-if (IncludeLoc.isInvalid() &&
-(F->Kind == MK_ImplicitModu

Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren added a comment.

Cheers,

Manman



Comment at: lib/Frontend/CompilerInstance.cpp:1502
@@ +1501,3 @@
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+if (!Module || !Module->getASTFile() ||
+std::string(Module->getASTFile()->getName()) != ModuleFileName) {

Thanks for the explanation, it makes sense.

Updated the patch accordingly.


https://reviews.llvm.org/D23125



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren added inline comments.


Comment at: lib/Frontend/CompilerInstance.cpp:1503
@@ +1502,3 @@
+if (!Module || !Module->getASTFile() ||
+std::string(Module->getASTFile()->getName()) != ModuleFileName) {
+  // Error out if Module does not refer to the file in the prebuilt

rsmith wrote:
> It'd be safer to check that `FileMgr.getFile(ModuleFileName) == 
> Module->getASTFile()` in case the filename gets canonicalized by the file 
> manager in some way.
Yes you are right. I will update the patch and commit the change.

Thanks for all the useful information!



https://reviews.llvm.org/D23125



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


r279096 - Module: add -fprebuilt-module-path to support loading prebuilt modules.

2016-08-18 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Aug 18 12:42:15 2016
New Revision: 279096

URL: http://llvm.org/viewvc/llvm-project?rev=279096&view=rev
Log:
Module: add -fprebuilt-module-path to support loading prebuilt modules.

In this mode, there is no need to load any module map and the programmer can
simply use "@import" syntax to load the module directly from a prebuilt
module path. When loading from prebuilt module path, we don't support
rebuilding of the module files and we ignore compatible configuration
mismatches.

rdar://27290316
Differential Revision: http://reviews.llvm.org/D23125

Added:
cfe/trunk/test/Modules/Inputs/prebuilt-module/
cfe/trunk/test/Modules/Inputs/prebuilt-module/a.h
cfe/trunk/test/Modules/Inputs/prebuilt-module/module.modulemap
cfe/trunk/test/Modules/prebuilt-module.m
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp
cfe/trunk/test/Driver/modules.m

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=279096&r1=279095&r2=279096&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Thu Aug 18 12:42:15 2016
@@ -213,6 +213,9 @@ Command-line parameters
 ``-fmodule-file=``
   Load the given precompiled module file.
 
+``-fprebuilt-module-path=``
+  Specify the path to the prebuilt modules. If specified, we will look for 
modules in this directory for a given top-level module name. We don't need a 
module map for loading prebuilt modules in this directory and the compiler will 
not try to rebuild these modules. This can be specified multiple times.
+
 Module Semantics
 
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=279096&r1=279095&r2=279096&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Aug 18 12:42:15 
2016
@@ -94,6 +94,8 @@ def err_module_lock_timeout : Error<
   "timed out waiting to acquire lock file for module '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
+def err_module_prebuilt : Error<
+  "error in loading module '%0' from prebuilt module path">, DefaultFatal;
 def note_pragma_entered_here : Note<"#pragma entered here">;  
 def note_decl_hiding_tag_type : Note<
   "%1 %0 is hidden by a non-type declaration of %0 here">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=279096&r1=279095&r2=279096&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug 18 12:42:15 2016
@@ -840,6 +840,9 @@ def fmodules_cache_path : Joined<["-"],
 def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, 
Group,
   Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the module user build path">;
+def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, 
Group,
+  Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
+  HelpText<"Specify the prebuilt module path">;
 def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, 
Group,
   Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the interval (in seconds) between attempts to prune the 
module cache">;

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=279096&r1=279095&r2=279096&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Thu Aug 18 12:42:15 2016
@@ -481,9 +481,12 @@ public:
   /// \param ModuleMapPath A path that when combined with \c ModuleName
   /// uniquely identifies this module. See Module::ModuleMap.
   ///
+  /// \param UsePrebuiltPath Whether we should use the prebuilt module path.
+  ///
   /// \returns The name of the module 

r279351 - [NFC] Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

2016-08-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Aug 19 19:04:21 2016
New Revision: 279351

URL: http://llvm.org/viewvc/llvm-project?rev=279351&view=rev
Log:
[NFC] Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

This is in preparation of adding a new type class ObjCTypeParamType that
can take protocol qualifiers. ObjCProtocolQualifiers will be shared between
ObjCObjectType and ObjCTypeParamType.

rdar://24619481
rdar://25060179

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

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=279351&r1=279350&r2=279351&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Aug 19 19:04:21 2016
@@ -4699,6 +4699,59 @@ public:
   }
 };
 
+/// This class wraps the list of protocol qualifiers. For types that can
+/// take ObjC protocol qualifers, they can subclass this class.
+template 
+class ObjCProtocolQualifiers {
+protected:
+  ObjCProtocolQualifiers() {}
+  ObjCProtocolDecl * const *getProtocolStorage() const {
+return const_cast(this)->getProtocolStorage();
+  }
+
+  ObjCProtocolDecl **getProtocolStorage() {
+return static_cast(this)->getProtocolStorageImpl();
+  }
+  void setNumProtocols(unsigned N) {
+static_cast(this)->setNumProtocolsImpl(N);
+  }
+  void initialize(ArrayRef protocols) {
+setNumProtocols(protocols.size());
+assert(getNumProtocols() == protocols.size() &&
+   "bitfield overflow in protocol count");
+if (!protocols.empty())
+  memcpy(getProtocolStorage(), protocols.data(),
+ protocols.size() * sizeof(ObjCProtocolDecl*));
+  }
+
+public:
+  typedef ObjCProtocolDecl * const *qual_iterator;
+  typedef llvm::iterator_range qual_range;
+
+  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
+  qual_iterator qual_begin() const { return getProtocolStorage(); }
+  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
+
+  bool qual_empty() const { return getNumProtocols() == 0; }
+
+  /// Return the number of qualifying protocols in this type, or 0 if
+  /// there are none.
+  unsigned getNumProtocols() const {
+return static_cast(this)->getNumProtocolsImpl();
+  }
+
+  /// Fetch a protocol by index.
+  ObjCProtocolDecl *getProtocol(unsigned I) const {
+assert(I < getNumProtocols() && "Out-of-range protocol access");
+return qual_begin()[I];
+  }
+
+  /// Retrieve all of the protocol qualifiers.
+  ArrayRef getProtocols() const {
+return ArrayRef(qual_begin(), getNumProtocols());
+  }
+};
+
 /// Represents a class type in Objective C.
 ///
 /// Every Objective C type is a combination of a base type, a set of
@@ -4727,7 +4780,9 @@ public:
 /// 'id' is an ObjCObjectPointerType whose pointee is an ObjCObjectType
 /// with base BuiltinType::ObjCIdType and protocol list [P].  Eventually
 /// this should get its own sugar class to better represent the source.
-class ObjCObjectType : public Type {
+class ObjCObjectType : public Type,
+   public ObjCProtocolQualifiers {
+  friend class ObjCProtocolQualifiers;
   // ObjCObjectType.NumTypeArgs - the number of type arguments stored
   // after the ObjCObjectPointerType node.
   // ObjCObjectType.NumProtocols - the number of protocols stored
@@ -4747,16 +4802,20 @@ class ObjCObjectType : public Type {
   mutable llvm::PointerIntPair
 CachedSuperClassType;
 
-  ObjCProtocolDecl * const *getProtocolStorage() const {
-return const_cast(this)->getProtocolStorage();
-  }
-
   QualType *getTypeArgStorage();
   const QualType *getTypeArgStorage() const {
 return const_cast(this)->getTypeArgStorage();
   }
 
-  ObjCProtocolDecl **getProtocolStorage();
+  ObjCProtocolDecl **getProtocolStorageImpl();
+  /// Return the number of qualifying protocols in this interface type,
+  /// or 0 if there are none.
+  unsigned getNumProtocolsImpl() const {
+return ObjCObjectTypeBits.NumProtocols;
+  }
+  void setNumProtocolsImpl(unsigned N) {
+ObjCObjectTypeBits.NumProtocols = N;
+  }
 
 protected:
   ObjCObjectType(QualType Canonical, QualType Base,
@@ -4833,30 +4892,6 @@ public:
   ObjCObjectTypeBits.NumTypeArgs);
   }
 
-  typedef ObjCProtocolDecl * const *qual_iterator;
-  typedef llvm::iterator_range qual_range;
-
-  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
-  qual_iterator qual_begin() const { return getProtocolStorage(); }
-  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
-
-  bool qual_empty() const { return getNumProtocols() == 0; }
-
-  /// Return the number of qualifying protocols in this interface type,
-  /// or 0 if there are none.
-  unsigned getNumProtocols() const { return ObjCObjectTypeBits.NumProtocols; }

Re: [PATCH] D23080: ObjC: Use a new type for ObjC type parameter (patch 3 out of 3)

2016-08-19 Thread Manman Ren via cfe-commits
manmanren added a comment.

I will update this patch once the 2nd patch is done.

Thanks for reviewing,
Manman



Comment at: lib/AST/Type.cpp:1095
@@ +1094,3 @@
+return ctx.getQualifiedType(argType, splitType.Quals);
+  // Apply protocol lists if exists. Should we combine protocol list?
+  if (const auto *objcPtr = dyn_cast(argType)) {

doug.gregor wrote:
> I think we should combine the protocol lists.
I did combine the protocol lists in the implementation, but forgot to remove 
the comments :]


Comment at: lib/AST/Type.cpp:1290
@@ +1289,3 @@
+/// in @implementation. @implementation does not take type parameters.
+QualType QualType::handleObjCTypeParamType(ASTContext &ctx) const {
+  return simpleTransform(ctx, *this,

doug.gregor wrote:
> I think you won't need this if you take the approach I suggested on the 
> previous patch of making ObjCTypeParamType type sugar for, effectively, the 
> type you're computing here.
I will update this once we fix the previous patch.


https://reviews.llvm.org/D23080



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


Re: [PATCH] D23079: ObjC: Use a new type for ObjC type parameter (patch 2 out of 3)

2016-08-19 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks for reviewing!

Manman



Comment at: include/clang/AST/RecursiveASTVisitor.h:1037
@@ -1036,1 +1036,3 @@
 
+DEF_TRAVERSE_TYPE(ObjCTypeParamType, {})
+

doug.gregor wrote:
> I'm sorta shocked that we don't visit the protocol qualifiers here, but I 
> guess we haven't been doing that for ObjCObjectType all along. Weird.
Right below, we don't visit the protocol qualifiers for ObjCObjectType :]
If you think we should, I can patch it up for both types.


Comment at: include/clang/AST/RecursiveASTVisitor.h:1270
@@ -1267,1 +1269,3 @@
 
+DEF_TRAVERSE_TYPELOC(ObjCTypeParamType, {})
+

doug.gregor wrote:
> Same shock at not visiting the protocol qualifiers here :)
Same here.


Comment at: include/clang/AST/Type.h:4786
@@ +4785,3 @@
+  bool isSugared() const { return false; }
+  QualType desugar() const { return QualType(this, 0); }
+

doug.gregor wrote:
> This is an interesting choice. Objective-C type parameters were treated like 
> typedefs before, so they always act like their underlying type (e.g., because 
> they are typedef name declarations). Why isn't ObjCTypeParamType sugar for 
> the underlying type of the type parameter (I.e., the bound) w/ the protocol 
> qualifiers?
Are you suggesting to canonicalize ObjCTypeParamType to the underlying type 
with the protocol qualifiers as well? Or just desugaring?

I think I have tried to set ObjCTypeParamType as NON_CANONICAL_TYPE in 
TypeNodes.def, but had some issues.


https://reviews.llvm.org/D23079



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


r279357 - Fix windows bot

2016-08-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Aug 19 21:28:15 2016
New Revision: 279357

URL: http://llvm.org/viewvc/llvm-project?rev=279357&view=rev
Log:
Fix windows bot

Modified:
cfe/trunk/include/clang/AST/Type.h

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=279357&r1=279356&r2=279357&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Aug 19 21:28:15 2016
@@ -4782,7 +4782,7 @@ public:
 /// this should get its own sugar class to better represent the source.
 class ObjCObjectType : public Type,
public ObjCProtocolQualifiers {
-  friend class ObjCProtocolQualifiers;
+  template  friend class ObjCProtocolQualifiers;
   // ObjCObjectType.NumTypeArgs - the number of type arguments stored
   // after the ObjCObjectPointerType node.
   // ObjCObjectType.NumProtocols - the number of protocols stored


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


r279358 - Revert r279351 and r279357 due to bot failures

2016-08-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Aug 19 22:00:54 2016
New Revision: 279358

URL: http://llvm.org/viewvc/llvm-project?rev=279358&view=rev
Log:
Revert r279351 and r279357 due to bot failures

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=279358&r1=279357&r2=279358&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Aug 19 22:00:54 2016
@@ -4699,59 +4699,6 @@ public:
   }
 };
 
-/// This class wraps the list of protocol qualifiers. For types that can
-/// take ObjC protocol qualifers, they can subclass this class.
-template 
-class ObjCProtocolQualifiers {
-protected:
-  ObjCProtocolQualifiers() {}
-  ObjCProtocolDecl * const *getProtocolStorage() const {
-return const_cast(this)->getProtocolStorage();
-  }
-
-  ObjCProtocolDecl **getProtocolStorage() {
-return static_cast(this)->getProtocolStorageImpl();
-  }
-  void setNumProtocols(unsigned N) {
-static_cast(this)->setNumProtocolsImpl(N);
-  }
-  void initialize(ArrayRef protocols) {
-setNumProtocols(protocols.size());
-assert(getNumProtocols() == protocols.size() &&
-   "bitfield overflow in protocol count");
-if (!protocols.empty())
-  memcpy(getProtocolStorage(), protocols.data(),
- protocols.size() * sizeof(ObjCProtocolDecl*));
-  }
-
-public:
-  typedef ObjCProtocolDecl * const *qual_iterator;
-  typedef llvm::iterator_range qual_range;
-
-  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
-  qual_iterator qual_begin() const { return getProtocolStorage(); }
-  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
-
-  bool qual_empty() const { return getNumProtocols() == 0; }
-
-  /// Return the number of qualifying protocols in this type, or 0 if
-  /// there are none.
-  unsigned getNumProtocols() const {
-return static_cast(this)->getNumProtocolsImpl();
-  }
-
-  /// Fetch a protocol by index.
-  ObjCProtocolDecl *getProtocol(unsigned I) const {
-assert(I < getNumProtocols() && "Out-of-range protocol access");
-return qual_begin()[I];
-  }
-
-  /// Retrieve all of the protocol qualifiers.
-  ArrayRef getProtocols() const {
-return ArrayRef(qual_begin(), getNumProtocols());
-  }
-};
-
 /// Represents a class type in Objective C.
 ///
 /// Every Objective C type is a combination of a base type, a set of
@@ -4780,9 +4727,7 @@ public:
 /// 'id' is an ObjCObjectPointerType whose pointee is an ObjCObjectType
 /// with base BuiltinType::ObjCIdType and protocol list [P].  Eventually
 /// this should get its own sugar class to better represent the source.
-class ObjCObjectType : public Type,
-   public ObjCProtocolQualifiers {
-  template  friend class ObjCProtocolQualifiers;
+class ObjCObjectType : public Type {
   // ObjCObjectType.NumTypeArgs - the number of type arguments stored
   // after the ObjCObjectPointerType node.
   // ObjCObjectType.NumProtocols - the number of protocols stored
@@ -4802,20 +4747,16 @@ class ObjCObjectType : public Type,
   mutable llvm::PointerIntPair
 CachedSuperClassType;
 
+  ObjCProtocolDecl * const *getProtocolStorage() const {
+return const_cast(this)->getProtocolStorage();
+  }
+
   QualType *getTypeArgStorage();
   const QualType *getTypeArgStorage() const {
 return const_cast(this)->getTypeArgStorage();
   }
 
-  ObjCProtocolDecl **getProtocolStorageImpl();
-  /// Return the number of qualifying protocols in this interface type,
-  /// or 0 if there are none.
-  unsigned getNumProtocolsImpl() const {
-return ObjCObjectTypeBits.NumProtocols;
-  }
-  void setNumProtocolsImpl(unsigned N) {
-ObjCObjectTypeBits.NumProtocols = N;
-  }
+  ObjCProtocolDecl **getProtocolStorage();
 
 protected:
   ObjCObjectType(QualType Canonical, QualType Base,
@@ -4892,6 +4833,30 @@ public:
   ObjCObjectTypeBits.NumTypeArgs);
   }
 
+  typedef ObjCProtocolDecl * const *qual_iterator;
+  typedef llvm::iterator_range qual_range;
+
+  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
+  qual_iterator qual_begin() const { return getProtocolStorage(); }
+  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
+
+  bool qual_empty() const { return getNumProtocols() == 0; }
+
+  /// Return the number of qualifying protocols in this interface type,
+  /// or 0 if there are none.
+  unsigned getNumProtocols() const { return ObjCObjectTypeBits.NumProtocols; }
+
+  /// Fetch a protocol by index.
+  ObjCProtocolDecl *getProtocol(unsigned I) const {
+assert(I < getNumProtocols() && "Out-of-range protocol access");
+return qual_begin()[I];
+  }
+
+  /// Retrieve all of the protocol qualifiers.
+  ArrayRef getProtocols() const {
+return ArrayRef(qu

[PATCH] D23858: Don't diagnose non-modular includes when we are not compiling a module

2016-08-24 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: rsmith, benlangmuir.
manmanren added a subscriber: cfe-commits.

We used to have -fmodule-implementation-of and it was merged with 
-fmodule-name. But this causes some regression on our internal projects. We are 
now seeing non-modular include warnings.

This is triggered when we have relative includes to a VFS-mapped module, -I 
that points us to the real header and -F that points us to the vfs. The real 
header that is part of the umbrella directory will be classified as non-modular.

It seems like we can use CompilingModule to tell if we are compiling the 
interface of a module or the implementation file of a module. When compiling 
the implementation file, we don't diagnose non-modular includes. The 
non-modular includes will be diagnosed when building the interface and writing 
the pcm file.

Related changes:
http://llvm.org/viewvc/llvm-project?rev=213767&view=rev
http://llvm.org/viewvc/llvm-project?rev=261372&view=rev
http://llvm.org/viewvc/llvm-project?rev=263449&view=rev

https://reviews.llvm.org/D23858

Files:
  lib/Lex/PPDirectives.cpp
  test/VFS/Inputs/Nonmodular/A.h
  test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
  test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
  test/VFS/Inputs/Nonmodular/test.c
  test/VFS/Inputs/Nonmodular/umbrella.h
  test/VFS/test_nonmodular.c

Index: test/VFS/test_nonmodular.c
===
--- test/VFS/test_nonmodular.c
+++ test/VFS/test_nonmodular.c
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/vdir %t/cache %t/outdir
+// We can't have module.map inside Inputs/Nonmodular.
+// RUN: cp %S/Inputs/Nonmodular/Nonmodular.modulemap %t/outdir/module.modulemap
+//
+// RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:IN_DIR:%S:g" -e "s:OUT_DIR:%t/outdir:g" %S/Inputs/Nonmodular/nonmodular-headers.yaml > %t/vdir/nonmodular-headers.yaml
+// RUN: %clang_cc1 -fmodule-name=Nonmodular -fmodules -Wnon-modular-include-in-framework-module -verify -fimplicit-module-maps -fmodules-cache-path=%t/cache -ivfsoverlay %t/vdir/nonmodular-headers.yaml -I %S/Inputs -F %t/vdir -fsyntax-only %S/Inputs/Nonmodular/test.c
+
+// expected-no-diagnostics
Index: test/VFS/Inputs/Nonmodular/umbrella.h
===
--- test/VFS/Inputs/Nonmodular/umbrella.h
+++ test/VFS/Inputs/Nonmodular/umbrella.h
@@ -0,0 +1,5 @@
+#ifndef __umbrella_h__
+#define __umbrella_h__
+
+#include 
+#endif
Index: test/VFS/Inputs/Nonmodular/test.c
===
--- test/VFS/Inputs/Nonmodular/test.c
+++ test/VFS/Inputs/Nonmodular/test.c
@@ -0,0 +1,3 @@
+// expected-no-diagnostics
+
+#include "umbrella.h"
Index: test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
===
--- test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
+++ test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
@@ -0,0 +1,34 @@
+{
+  'version': 0,
+  'case-sensitive': 'false',
+  'ignore-non-existent-contents': 'true',
+  'roots': [
+{
+  'type': 'directory',
+  'name': "VDIR/Nonmodular.framework/Headers",
+  'contents': [
+{
+  'type': 'file',
+  'name': "umbrella.h",
+  'external-contents': "IN_DIR/Inputs/Nonmodular/umbrella.h"
+},
+{
+  'type': 'file',
+  'name': "A.h",
+  'external-contents': "IN_DIR/Inputs/Nonmodular/A.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "VDIR/Nonmodular.framework/Modules",
+  'contents': [
+{
+  'type': 'file',
+  'name': "module.modulemap",
+  'external-contents': "OUT_DIR/module.modulemap"
+}
+  ]
+}
+  ]
+}
Index: test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
===
--- test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
+++ test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
@@ -0,0 +1,5 @@
+framework module Nonmodular [extern_c] {
+  umbrella header "umbrella.h"
+  export *
+  module * { export * }
+}
Index: test/VFS/Inputs/Nonmodular/A.h
===
--- test/VFS/Inputs/Nonmodular/A.h
+++ test/VFS/Inputs/Nonmodular/A.h
@@ -0,0 +1 @@
+// A.h
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -746,7 +746,8 @@
 ModuleMap::KnownHeader *SuggestedModule,
 bool SkipCache) {
   Module *RequestingModule = getModuleForLocation(FilenameLoc);
-  bool RequestingModuleIsModuleInterface = !SourceMgr.isInMainFile(FilenameLoc);
+  bool RequestingModuleIsModuleInterface =
+  !SourceMgr.isInMainFile(FilenameLoc) && getLangOpts().CompilingModule;
 
   // If the header lookup mechanism may be relative to the current inclusion
   // stack, record the par

Re: [PATCH] D23858: Don't diagnose non-modular includes when we are not compiling a module

2016-08-25 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D23858#525647, @rsmith wrote:

> It seems to me like this is papering over an issue rather than fixing it.


I guess that is why we introduced fmodule-implementation-of, to work around 
issues like "relative includes to a VFS-mapped module". Ben should know more 
about the background.

> `diagnoseHeaderInclusion` calls `isHeaderInUmbrellaDirs` here, which is 
> presumably failing to determine that `Nonmodular/A.h` is in the umbrella 
> directory for the `Nonmodular` module.


Bruno and I looked at this together yesterday. With vfsoverlay, the header 
files in the module map are using the real path, while the umbrella directories 
in the module map are using the virtual path. We have issue figuring out the 
header file from the real path is in the umbrella directory. We have longer 
term goals on fixing up this. But this is a regression on our side and we are 
hoping to get back to our previous behavior.

Cheers,
Manman



Comment at: lib/Lex/PPDirectives.cpp:749-750
@@ -748,3 +748,4 @@
   Module *RequestingModule = getModuleForLocation(FilenameLoc);
-  bool RequestingModuleIsModuleInterface = 
!SourceMgr.isInMainFile(FilenameLoc);
+  bool RequestingModuleIsModuleInterface =
+  !SourceMgr.isInMainFile(FilenameLoc) && getLangOpts().CompilingModule;
 

rsmith wrote:
> I don't see why this should depend on whether we're compiling a module. If 
> we're asked to diagnose non-modular #includes in modular headers, why should 
> it matter whether we entered that header textually or by triggering 
> precompilation of the corresponding module?
I agree that here, we are actually including a non modular header from a 
modular header. But is it okay to not diagnose when we have specified 
fmodule-name and we are building the implementation of it? We should have 
diagnosed this when building the unit.


https://reviews.llvm.org/D23858



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


r279838 - Don't diagnose non-modular includes when we are not compiling a module.

2016-08-26 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Aug 26 12:16:46 2016
New Revision: 279838

URL: http://llvm.org/viewvc/llvm-project?rev=279838&view=rev
Log:
Don't diagnose non-modular includes when we are not compiling a module.

This is triggered when we are compiling an implementation of a module,
it has relative includes to a VFS-mapped module with umbrella headers.
Currently we will find the real path to headers under the umbrella directory,
but the umbrella directories are using virtual path.

rdar://27951255

Thanks Ben and Richard for reviewing the patch!
Differential Revision: http://reviews.llvm.org/D23858

Added:
cfe/trunk/test/VFS/Inputs/Nonmodular/
cfe/trunk/test/VFS/Inputs/Nonmodular/A.h
cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
cfe/trunk/test/VFS/Inputs/Nonmodular/test.c
cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h
cfe/trunk/test/VFS/test_nonmodular.c
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=279838&r1=279837&r2=279838&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Aug 26 12:16:46 2016
@@ -297,7 +297,9 @@ void ModuleMap::diagnoseHeaderInclusion(
   if (LangOpts.ModulesStrictDeclUse) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
 << RequestingModule->getFullModuleName() << Filename;
-  } else if (RequestingModule && RequestingModuleIsModuleInterface) {
+  } else if (RequestingModule && RequestingModuleIsModuleInterface &&
+ LangOpts.isCompilingModule()) {
+// Do not diagnose when we are not compiling a module. 
 diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ?
 diag::warn_non_modular_include_in_framework_module :
 diag::warn_non_modular_include_in_module;

Added: cfe/trunk/test/VFS/Inputs/Nonmodular/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/A.h?rev=279838&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Nonmodular/A.h (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/A.h Fri Aug 26 12:16:46 2016
@@ -0,0 +1 @@
+// A.h

Added: cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap?rev=279838&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/Nonmodular.modulemap Fri Aug 26 
12:16:46 2016
@@ -0,0 +1,5 @@
+framework module Nonmodular [extern_c] {
+  umbrella header "umbrella.h"
+  export *
+  module * { export * }
+}

Added: cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml?rev=279838&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml Fri Aug 26 
12:16:46 2016
@@ -0,0 +1,34 @@
+{
+  'version': 0,
+  'case-sensitive': 'false',
+  'ignore-non-existent-contents': 'true',
+  'roots': [
+{
+  'type': 'directory',
+  'name': "VDIR/Nonmodular.framework/Headers",
+  'contents': [
+{
+  'type': 'file',
+  'name': "umbrella.h",
+  'external-contents': "IN_DIR/Inputs/Nonmodular/umbrella.h"
+},
+{
+  'type': 'file',
+  'name': "A.h",
+  'external-contents': "IN_DIR/Inputs/Nonmodular/A.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "VDIR/Nonmodular.framework/Modules",
+  'contents': [
+{
+  'type': 'file',
+  'name': "module.modulemap",
+  'external-contents': "OUT_DIR/module.modulemap"
+}
+  ]
+}
+  ]
+}

Added: cfe/trunk/test/VFS/Inputs/Nonmodular/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/test.c?rev=279838&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Nonmodular/test.c (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/test.c Fri Aug 26 12:16:46 2016
@@ -0,0 +1,3 @@
+// expected-no-diagnostics
+
+#include "umbrella.h"

Added: cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h?rev=279838&view=auto
==
--- cfe/trunk/test/VFS/Inputs/Nonmodular/umbrella.h (added)
+++ cfe/trunk/test/VFS/Inputs/Nonmodular/umbrell

Re: [PATCH] D23079: ObjC: Use a new type for ObjC type parameter (patch 2 out of 3)

2016-08-30 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 69764.
manmanren added a comment.

Address Doug's comment. ObjCTypeParamType is a non-canonical type now, it is 
canonicalized to the underlying type with protocol qualifiers.


https://reviews.llvm.org/D23079

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/AST/TypeNodes.def
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1534,6 +1534,18 @@
   return Visit(MakeCursorObjCClassRef(TL.getIFaceDecl(), TL.getNameLoc(), TU));
 }
 
+bool CursorVisitor::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  if (Visit(MakeCursorTypeRef(TL.getDecl(), TL.getLocStart(), TU)))
+return true;
+  for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
+if (Visit(MakeCursorObjCProtocolRef(TL.getProtocol(I), TL.getProtocolLoc(I),
+TU)))
+  return true;
+  }
+
+  return false;
+}
+
 bool CursorVisitor::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
   if (TL.hasBaseTypeAsWritten() && Visit(TL.getBaseLoc()))
 return true;
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -450,6 +450,14 @@
   Code = TYPE_OBJC_INTERFACE;
 }
 
+void ASTTypeWriter::VisitObjCTypeParamType(const ObjCTypeParamType *T) {
+  Record.AddDeclRef(T->getDecl());
+  Record.push_back(T->getNumProtocols());
+  for (const auto *I : T->quals())
+Record.AddDeclRef(I);
+  Code = TYPE_OBJC_TYPE_PARAM;
+}
+
 void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
   Record.AddTypeRef(T->getBaseType());
   Record.push_back(T->getTypeArgsAsWritten().size());
@@ -587,6 +595,14 @@
 void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
   Record.AddSourceLocation(TL.getNameLoc());
 }
+void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  if (TL.getNumProtocols()) {
+Record.AddSourceLocation(TL.getProtocolLAngleLoc());
+Record.AddSourceLocation(TL.getProtocolRAngleLoc());
+  }
+  for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+Record.AddSourceLocation(TL.getProtocolLoc(i));
+}
 void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
   Record.AddSourceLocation(TL.getTypeofLoc());
   Record.AddSourceLocation(TL.getLParenLoc());
@@ -1066,6 +1082,7 @@
   RECORD(TYPE_ATOMIC);
   RECORD(TYPE_DECAYED);
   RECORD(TYPE_ADJUSTED);
+  RECORD(TYPE_OBJC_TYPE_PARAM);
   RECORD(LOCAL_REDECLARATIONS);
   RECORD(DECL_TYPEDEF);
   RECORD(DECL_TYPEALIAS);
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5546,6 +5546,16 @@
 return Context.getObjCInterfaceType(ItfD->getCanonicalDecl());
   }
 
+  case TYPE_OBJC_TYPE_PARAM: {
+unsigned Idx = 0;
+ObjCTypeParamDecl *Decl
+  = ReadDeclAs(*Loc.F, Record, Idx);
+unsigned NumProtos = Record[Idx++];
+SmallVector Protos;
+for (unsigned I = 0; I != NumProtos; ++I)
+  Protos.push_back(ReadDeclAs(*Loc.F, Record, Idx));
+return Context.getObjCTypeParamType(Decl, Protos);
+  }
   case TYPE_OBJC_OBJECT: {
 unsigned Idx = 0;
 QualType Base = readType(*Loc.F, Record, Idx);
@@ -5944,6 +5954,15 @@
 void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation(Record, Idx));
 }
+void TypeLocReader::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  if (TL.getNumProtocols()) {
+TL.setProtocolLAngleLoc(ReadSourceLocation(Record, Idx));
+TL.setProtocolRAngleLoc(ReadSourceLocation(Record, Idx));
+  }
+  for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+TL.setProtocolLoc(i, ReadSourceLocation(Record, Idx));
+}
+
 void TypeLocReader::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
   TL.setHasBaseTypeAsWritten(Record[Idx++]);
   TL.setTypeArgsLAngleLoc(ReadSourceLocation(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -699,6 +699,12 @@
   QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType,
 SourceLocation Sigil);
 
+  QualType Rebui

Re: [PATCH] D23080: ObjC: Use a new type for ObjC type parameter (patch 3 out of 3)

2016-08-30 Thread Manman Ren via cfe-commits
manmanren updated the summary for this revision.
manmanren updated this revision to Diff 69765.
manmanren added a comment.

This patch is now much simpler with the updated version of 
https://reviews.llvm.org/D23079.


https://reviews.llvm.org/D23080

Files:
  lib/AST/ASTContext.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaType.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  test/SemaObjC/kindof.m
  test/SemaObjC/parameterized_classes_subst.m

Index: test/SemaObjC/parameterized_classes_subst.m
===
--- test/SemaObjC/parameterized_classes_subst.m
+++ test/SemaObjC/parameterized_classes_subst.m
@@ -426,3 +426,36 @@
 // warning about likely protocol/class name typos.
 // --
 typedef NSArray ArrayOfNSObjectWarning; // expected-warning{{parameterized class 'NSArray' already conforms to the protocols listed; did you forget a '*'?}}
+
+// rdar://25060179
+@interface MyMutableDictionary : NSObject
+- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType )key; // expected-note{{passing argument to parameter 'obj' here}} \
+// expected-note{{passing argument to parameter 'key' here}}
+@end
+
+void bar(MyMutableDictionary *stringsByString,
+ NSNumber *n1, NSNumber *n2) {
+  // We warn here when the key types do not match.
+  stringsByString[n1] = n2; // expected-warning{{incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString *'}} \
+// expected-warning{{incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString *'}}
+}
+
+@interface MyTest : NSObject 
+- (V)test:(K)key;
+- (V)test2:(K)key; // expected-note{{previous definition is here}}
+- (void)mapUsingBlock:(id (^)(V))block;
+- (void)mapUsingBlock2:(id (^)(V))block; // expected-note{{previous definition is here}}
+@end
+
+@implementation MyTest
+- (id)test:(id)key {
+  return key;
+}
+- (int)test2:(id)key{ // expected-warning{{conflicting return type in implementation}}
+  return 0;
+}
+- (void)mapUsingBlock:(id (^)(id))block {
+}
+- (void)mapUsingBlock2:(id)block { // expected-warning{{conflicting parameter types in implementation}}
+}
+@end
Index: test/SemaObjC/kindof.m
===
--- test/SemaObjC/kindof.m
+++ test/SemaObjC/kindof.m
@@ -385,7 +385,7 @@
 @end
 
 @interface NSGeneric : NSObject
-- (void)test:(__kindof ObjectType)T;
+- (void)test:(__kindof ObjectType)T; // expected-note{{passing argument to parameter 'T' here}}
 - (void)mapUsingBlock:(id (^)(__kindof ObjectType))block;
 @end
 @implementation NSGeneric
@@ -395,6 +395,14 @@
 }
 @end
 
+void testGeneric(NSGeneric *generic) {
+  NSObject *NSObject_obj;
+  // Assign from NSObject_obj to __kindof NSString*.
+  [generic test:NSObject_obj]; // expected-warning{{incompatible pointer types sending 'NSObject *' to parameter of type '__kindof NSString *'}}
+  NSString *NSString_str;
+  [generic test:NSString_str];
+}
+
 // Check that clang doesn't crash when a type parameter is illegal.
 @interface Array1 : NSObject
 @end
Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -626,7 +626,7 @@
   : public RecursiveASTVisitor {
   public:
 IsObjCTypeParamDependentTypeVisitor() : Result(false) {}
-bool VisitTypedefType(const TypedefType *Type) {
+bool VisitObjCTypeParamType(const ObjCTypeParamType *Type) {
   if (isa(Type->getDecl())) {
 Result = true;
 return false;
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1157,6 +1157,20 @@
 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
   }
 
+  if (auto OTPTL = ResultTL.getAs()) {
+// Protocol qualifier information.
+if (OTPTL.getNumProtocols() > 0) {
+  assert(OTPTL.getNumProtocols() == Protocols.size());
+  OTPTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
+  OTPTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
+  for (unsigned i = 0, n = Protocols.size(); i != n; ++i)
+OTPTL.setProtocolLoc(i, ProtocolLocs[i]);
+}
+
+// We're done. Return the completed type to the parser.
+return CreateParsedType(Result, ResultTInfo);
+  }
+
   auto ObjCObjectTL = ResultTL.castAs();
 
   // Type argument information.
@@ -5875,7 +5889,6 @@
   // For the context-sensitive keywords/Objective-C property
   // attributes, require that the type be a single-level pointer.
   if (isContextSensitive) {
-// Make sure that the pointee isn't itself a pointer type.
 QualType pointeeType = desugared->getPointeeType();
 if (pointeeType->isAnyPointerType() ||
 pointeeType->isObjC

[PATCH] D24059: NFC: refactor applyObjCProtocolQualifiers from SemaType.cpp to ASTContext so it can be shared.

2016-08-30 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added a reviewer: doug.gregor.
manmanren added a subscriber: cfe-commits.

To construct the canonical type of ObjCTypeParamType, we need to apply 
qualifiers on ObjCObjectPointerType. The updated applyObjCProtocolQualifiers 
handles this case by merging the protocol lists, constructing a new 
ObjCObjectType, then a new ObjCObjectPointerType.

https://reviews.llvm.org/D24059

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/Sema/SemaType.cpp

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1000,57 +1000,6 @@
   return S.Context.getObjCObjectType(type, finalTypeArgs, { }, false);
 }
 
-/// Apply Objective-C protocol qualifiers to the given type.
-static QualType applyObjCProtocolQualifiers(
-  Sema &S, SourceLocation loc, SourceRange range, QualType type,
-  ArrayRef protocols,
-  const SourceLocation *protocolLocs,
-  bool failOnError = false) {
-  ASTContext &ctx = S.Context;
-  if (const ObjCObjectType *objT = dyn_cast(type.getTypePtr())){
-// FIXME: Check for protocols to which the class type is already
-// known to conform.
-
-return ctx.getObjCObjectType(objT->getBaseType(),
- objT->getTypeArgsAsWritten(),
- protocols,
- objT->isKindOfTypeAsWritten());
-  }
-
-  if (type->isObjCObjectType()) {
-// Silently overwrite any existing protocol qualifiers.
-// TODO: determine whether that's the right thing to do.
-
-// FIXME: Check for protocols to which the class type is already
-// known to conform.
-return ctx.getObjCObjectType(type, { }, protocols, false);
-  }
-
-  // id
-  if (type->isObjCIdType()) {
-const ObjCObjectPointerType *objPtr = type->castAs();
-type = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, { }, protocols,
- objPtr->isKindOfType());
-return ctx.getObjCObjectPointerType(type);
-  }
-
-  // Class
-  if (type->isObjCClassType()) {
-const ObjCObjectPointerType *objPtr = type->castAs();
-type = ctx.getObjCObjectType(ctx.ObjCBuiltinClassTy, { }, protocols,
- objPtr->isKindOfType());
-return ctx.getObjCObjectPointerType(type);
-  }
-
-  S.Diag(loc, diag::err_invalid_protocol_qualifiers)
-<< range;
-
-  if (failOnError)
-return QualType();
-
-  return type;
-}
-
 QualType Sema::BuildObjCObjectType(QualType BaseType,
SourceLocation Loc,
SourceLocation TypeArgsLAngleLoc,
@@ -1072,12 +1021,14 @@
   }
 
   if (!Protocols.empty()) {
-Result = applyObjCProtocolQualifiers(*this, Loc,
- SourceRange(ProtocolLAngleLoc,
- ProtocolRAngleLoc),
- Result, Protocols,
- ProtocolLocs.data(),
- FailOnError);
+bool HasError;
+Result = Context.applyObjCProtocolQualifiers(Result, Protocols,
+ HasError);
+if (HasError) {
+  Diag(Loc, diag::err_invalid_protocol_qualifiers)
+<< SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
+  if (FailOnError) Result = QualType();
+}
 if (FailOnError && Result.isNull())
   return QualType();
   }
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -3871,6 +3871,76 @@
   return QualType(T, 0);
 }
 
+/// Apply Objective-C protocol qualifiers to the given type.
+/// If this is for the canonical type of a type parameter, we can apply
+/// protocol qualifiers on the ObjCObjectPointerType.
+QualType
+ASTContext::applyObjCProtocolQualifiers(QualType type,
+  ArrayRef protocols, bool &hasError,
+  bool allowOnPointerType) const {
+  hasError = false;
+
+  // Apply protocol qualifiers to ObjCObjectPointerType.
+  if (allowOnPointerType) {
+if (const ObjCObjectPointerType *objPtr =
+dyn_cast(type.getTypePtr())) {
+  const ObjCObjectType *objT = objPtr->getObjectType();
+  // Merge protocol lists and construct ObjCObjectType.
+  SmallVector protocolsVec;
+  protocolsVec.append(objT->qual_begin(),
+  objT->qual_end());
+  protocolsVec.append(protocols.begin(), protocols.end());
+  ArrayRef protocols = protocolsVec;
+  type = getObjCObjectType(
+ objT->getBaseType(),
+ objT->getTypeArgsAsWritten(),
+ protocols,
+ objT->isKindOfTypeAsWritten());
+  return getObjCObjectPointerType(type);
+}
+  }
+
+  // Apply protocol qualifiers to

r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-06 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep  6 13:16:54 2016
New Revision: 280728

URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
Log:
Modules: Fix an assertion in DeclContext::buildLookup.

When calling getMostRecentDecl, we can pull in more definitions from
a module. We call getPrimaryContext afterwards to make sure that
we buildLookup on a primary context.

rdar://27926200

Added:
cfe/trunk/test/Modules/Inputs/lookup-assert/
cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
cfe/trunk/test/Modules/lookup-assert.m
Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=280728&r1=280727&r2=280728&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
@@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
   assert(DeclKind != Decl::LinkageSpec &&
  "Should not perform lookups into linkage specs!");
 
-  const DeclContext *PrimaryContext = getPrimaryContext();
-  if (PrimaryContext != this)
-return PrimaryContext->lookup(Name);
-
   // If we have an external source, ensure that any later redeclarations of 
this
   // context have been loaded, since they may add names to the result of this
   // lookup (or add external visible storage).
@@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
   if (Source)
 (void)cast(this)->getMostRecentDecl();
 
+  // getMostRecentDecl can change the result of getPrimaryContext. Call
+  // getPrimaryContext afterwards.
+  const DeclContext *PrimaryContext = getPrimaryContext();
+  if (PrimaryContext != this)
+return PrimaryContext->lookup(Name);
+
   if (hasExternalVisibleStorage()) {
 assert(Source && "external visible storage but no external source?");
 

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h?rev=280728&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h Tue Sep  6 13:16:54 2016
@@ -0,0 +1,4 @@
+@interface BaseInterface
+- (void) test;
+@end
+

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h?rev=280728&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h Tue Sep  6 13:16:54 
2016
@@ -0,0 +1,3 @@
+#include "Base.h"
+@interface DerivedInterface : BaseInterface
+@end

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h?rev=280728&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h Tue Sep  6 13:16:54 2016
@@ -0,0 +1 @@
+#include "Base.h"

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/module.map?rev=280728&view=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/module.map (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/module.map Tue Sep  6 13:16:54 
2016
@@ -0,0 +1,4 @@
+module X {
+  header "H3.h"
+  export *
+}

Added: cfe/trunk/test/Modules/lookup-assert.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup-assert.m?rev=280728&view=auto
==
--- cfe/trunk/test/Modules/lookup-assert.m (added)
+++ cfe/trunk/test/Modules/lookup-assert.m Tue Sep  6 13:16:54 2016
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/lookup-assert %s -verify
+// expected-no-diagnostics
+
+#include "Derive.h"
+#import 
+@implementation DerivedInterface
+- (void)test {
+}
+@end


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


Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-07 Thread Manman Ren via cfe-commits
On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith  wrote:

> On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: mren
>> Date: Tue Sep  6 13:16:54 2016
>> New Revision: 280728
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
>> Log:
>> Modules: Fix an assertion in DeclContext::buildLookup.
>>
>> When calling getMostRecentDecl, we can pull in more definitions from
>> a module. We call getPrimaryContext afterwards to make sure that
>> we buildLookup on a primary context.
>>
>> rdar://27926200
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/lookup-assert/
>> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
>> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
>> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
>> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
>> cfe/trunk/test/Modules/lookup-assert.m
>> Modified:
>> cfe/trunk/lib/AST/DeclBase.cpp
>>
>> Modified: cfe/trunk/lib/AST/DeclBase.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
>> se.cpp?rev=280728&r1=280727&r2=280728&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
>> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>>assert(DeclKind != Decl::LinkageSpec &&
>>   "Should not perform lookups into linkage specs!");
>>
>> -  const DeclContext *PrimaryContext = getPrimaryContext();
>> -  if (PrimaryContext != this)
>> -return PrimaryContext->lookup(Name);
>> -
>>// If we have an external source, ensure that any later redeclarations
>> of this
>>// context have been loaded, since they may add names to the result of
>> this
>>// lookup (or add external visible storage).
>> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>>if (Source)
>>  (void)cast(this)->getMostRecentDecl();
>>
>> +  // getMostRecentDecl can change the result of getPrimaryContext. Call
>> +  // getPrimaryContext afterwards.
>> +  const DeclContext *PrimaryContext = getPrimaryContext();
>> +  if (PrimaryContext != this)
>> +return PrimaryContext->lookup(Name);
>>
>
> This seems like a bug in getPrimaryContext() -- if there is a
> not-yet-loaded definition of the DeclContext, getPrimaryContext() should
> return that instead of returning a non-defining declaration. Why is
> ObjCInterfaceDecl::hasDefinition (indirectly called by getPrimaryContext)
> not loading the definition in this case?
>

In the testing case, we have a definition of the ObjC interface from
textually including a header file, but the definition is also in a module.
getPrimaryContext for ObjCInterface currently does not  pull from the
external source. Since getPrimaryContext  does not guarantee to pull from
the external source, I thought that is why we call getMostRecentDecl in
DeclContext::lookup.

Are you suggesting to pull from external source in getPrimaryContext?

Cheers,
Manman



>
>> +
>>if (hasExternalVisibleStorage()) {
>>  assert(Source && "external visible storage but no external source?");
>>
>>
>> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/I
>> nputs/lookup-assert/Base.h?rev=280728&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h Tue Sep  6
>> 13:16:54 2016
>> @@ -0,0 +1,4 @@
>> +@interface BaseInterface
>> +- (void) test;
>> +@end
>> +
>>
>> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/I
>> nputs/lookup-assert/Derive.h?rev=280728&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h Tue Sep  6
>> 13:16:54 2016
>> @@ -0,0 +1,3 @@
>> +#include "Base.h"
>> +@interface DerivedInterface : BaseInterface
>> +@end
>>
>> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
>> URL: http://llvm.org/viewvc/llvm-project/

Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-09 Thread Manman Ren via cfe-commits
On Wed, Sep 7, 2016 at 4:44 PM, Richard Smith  wrote:

> On Wed, Sep 7, 2016 at 12:45 PM, Manman Ren  wrote:
>
>> On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith 
>> wrote:
>>
>>> On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: mren
>>>> Date: Tue Sep  6 13:16:54 2016
>>>> New Revision: 280728
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
>>>> Log:
>>>> Modules: Fix an assertion in DeclContext::buildLookup.
>>>>
>>>> When calling getMostRecentDecl, we can pull in more definitions from
>>>> a module. We call getPrimaryContext afterwards to make sure that
>>>> we buildLookup on a primary context.
>>>>
>>>> rdar://27926200
>>>>
>>>> Added:
>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/
>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
>>>> cfe/trunk/test/Modules/lookup-assert.m
>>>> Modified:
>>>> cfe/trunk/lib/AST/DeclBase.cpp
>>>>
>>>> Modified: cfe/trunk/lib/AST/DeclBase.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
>>>> se.cpp?rev=280728&r1=280727&r2=280728&view=diff
>>>> 
>>>> ==
>>>> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
>>>> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
>>>> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>>>>assert(DeclKind != Decl::LinkageSpec &&
>>>>   "Should not perform lookups into linkage specs!");
>>>>
>>>> -  const DeclContext *PrimaryContext = getPrimaryContext();
>>>> -  if (PrimaryContext != this)
>>>> -return PrimaryContext->lookup(Name);
>>>> -
>>>>// If we have an external source, ensure that any later
>>>> redeclarations of this
>>>>// context have been loaded, since they may add names to the result
>>>> of this
>>>>// lookup (or add external visible storage).
>>>> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>>>>if (Source)
>>>>  (void)cast(this)->getMostRecentDecl();
>>>>
>>>> +  // getMostRecentDecl can change the result of getPrimaryContext. Call
>>>> +  // getPrimaryContext afterwards.
>>>> +  const DeclContext *PrimaryContext = getPrimaryContext();
>>>> +  if (PrimaryContext != this)
>>>> +return PrimaryContext->lookup(Name);
>>>>
>>>
>>> This seems like a bug in getPrimaryContext() -- if there is a
>>> not-yet-loaded definition of the DeclContext, getPrimaryContext() should
>>> return that instead of returning a non-defining declaration. Why is
>>> ObjCInterfaceDecl::hasDefinition (indirectly called by
>>> getPrimaryContext) not loading the definition in this case?
>>>
>>
>> In the testing case, we have a definition of the ObjC interface from
>> textually including a header file, but the definition is also in a module.
>> getPrimaryContext for ObjCInterface currently does not  pull from the
>> external source.
>>
>
> As far as I can see, it does. For ObjCInterface, getPrimaryContext calls
> ObjCInterface::getDefinition:
>
>   ObjCInterfaceDecl *getDefinition() {
> return hasDefinition()? Data.getPointer()->Definition : nullptr;
>   }
>
> hasDefinition() pulls from the external source to find a definition, if it
> believes the definition is out of date:
>
>   bool hasDefinition() const {
> // If the name of this class is out-of-date, bring it up-to-date, which
> // might bring in a definition.
> // Note: a null value indicates that we don't have a definition and
> that
> // modules are enabled.
> if (!Data.getOpaqueValue())
>   getMostRecentDecl();
>
> return Data.getPointer();
>   }
>
--> You are right, this is the backtrace when calling getPrimaryContext.
  * frame #0: 0x000102e6c1b0
clang`clang::ObjCInterfaceDecl::hasDefinition(this=0x00010f079a38)
const + 16 at DeclObjC.h:1445
frame #1: 0x000105d09009
clan

Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-09 Thread Manman Ren via cfe-commits
On Fri, Sep 9, 2016 at 11:33 AM, Richard Smith 
wrote:

> On Fri, Sep 9, 2016 at 11:29 AM, Manman Ren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Wed, Sep 7, 2016 at 4:44 PM, Richard Smith 
>> wrote:
>>
>>> On Wed, Sep 7, 2016 at 12:45 PM, Manman Ren 
>>> wrote:
>>>
>>>> On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith 
>>>> wrote:
>>>>
>>>>> On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>
>>>>>> Author: mren
>>>>>> Date: Tue Sep  6 13:16:54 2016
>>>>>> New Revision: 280728
>>>>>>
>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
>>>>>> Log:
>>>>>> Modules: Fix an assertion in DeclContext::buildLookup.
>>>>>>
>>>>>> When calling getMostRecentDecl, we can pull in more definitions from
>>>>>> a module. We call getPrimaryContext afterwards to make sure that
>>>>>> we buildLookup on a primary context.
>>>>>>
>>>>>> rdar://27926200
>>>>>>
>>>>>> Added:
>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/
>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
>>>>>> cfe/trunk/test/Modules/lookup-assert.m
>>>>>> Modified:
>>>>>> cfe/trunk/lib/AST/DeclBase.cpp
>>>>>>
>>>>>> Modified: cfe/trunk/lib/AST/DeclBase.cpp
>>>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
>>>>>> se.cpp?rev=280728&r1=280727&r2=280728&view=diff
>>>>>> 
>>>>>> ==
>>>>>> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
>>>>>> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
>>>>>> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>>>>>>assert(DeclKind != Decl::LinkageSpec &&
>>>>>>   "Should not perform lookups into linkage specs!");
>>>>>>
>>>>>> -  const DeclContext *PrimaryContext = getPrimaryContext();
>>>>>> -  if (PrimaryContext != this)
>>>>>> -return PrimaryContext->lookup(Name);
>>>>>> -
>>>>>>// If we have an external source, ensure that any later
>>>>>> redeclarations of this
>>>>>>// context have been loaded, since they may add names to the
>>>>>> result of this
>>>>>>// lookup (or add external visible storage).
>>>>>> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>>>>>>if (Source)
>>>>>>  (void)cast(this)->getMostRecentDecl();
>>>>>>
>>>>>> +  // getMostRecentDecl can change the result of getPrimaryContext.
>>>>>> Call
>>>>>> +  // getPrimaryContext afterwards.
>>>>>> +  const DeclContext *PrimaryContext = getPrimaryContext();
>>>>>> +  if (PrimaryContext != this)
>>>>>> +return PrimaryContext->lookup(Name);
>>>>>>
>>>>>
>>>>> This seems like a bug in getPrimaryContext() -- if there is a
>>>>> not-yet-loaded definition of the DeclContext, getPrimaryContext() should
>>>>> return that instead of returning a non-defining declaration. Why is
>>>>> ObjCInterfaceDecl::hasDefinition (indirectly called by
>>>>> getPrimaryContext) not loading the definition in this case?
>>>>>
>>>>
>>>> In the testing case, we have a definition of the ObjC interface from
>>>> textually including a header file, but the definition is also in a module.
>>>> getPrimaryContext for ObjCInterface currently does not  pull from the
>>>> external source.
>>>>
>>>
>>> As far as I can see, it does. For ObjCInterface, getPrimaryContext calls
>>> ObjCInterface::getDefinition:
>>>
>>>   ObjCInterfaceDecl *getDef

r281078 - Modules: revert r280728.

2016-09-09 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Sep  9 14:03:07 2016
New Revision: 281078

URL: http://llvm.org/viewvc/llvm-project?rev=281078&view=rev
Log:
Modules: revert r280728.

In post-commit review, Richard suggested a better way to fix this.
rdar://27926200

Removed:
cfe/trunk/test/Modules/Inputs/lookup-assert/
cfe/trunk/test/Modules/lookup-assert.m
Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=281078&r1=281077&r2=281078&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Sep  9 14:03:07 2016
@@ -1413,6 +1413,10 @@ DeclContext::lookup(DeclarationName Name
   assert(DeclKind != Decl::LinkageSpec && DeclKind != Decl::Export &&
  "should not perform lookups into transparent contexts");
 
+  const DeclContext *PrimaryContext = getPrimaryContext();
+  if (PrimaryContext != this)
+return PrimaryContext->lookup(Name);
+
   // If we have an external source, ensure that any later redeclarations of 
this
   // context have been loaded, since they may add names to the result of this
   // lookup (or add external visible storage).
@@ -1420,12 +1424,6 @@ DeclContext::lookup(DeclarationName Name
   if (Source)
 (void)cast(this)->getMostRecentDecl();
 
-  // getMostRecentDecl can change the result of getPrimaryContext. Call
-  // getPrimaryContext afterwards.
-  const DeclContext *PrimaryContext = getPrimaryContext();
-  if (PrimaryContext != this)
-return PrimaryContext->lookup(Name);
-
   if (hasExternalVisibleStorage()) {
 assert(Source && "external visible storage but no external source?");
 

Removed: cfe/trunk/test/Modules/lookup-assert.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup-assert.m?rev=281077&view=auto
==
--- cfe/trunk/test/Modules/lookup-assert.m (original)
+++ cfe/trunk/test/Modules/lookup-assert.m (removed)
@@ -1,10 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/lookup-assert %s -verify
-// expected-no-diagnostics
-
-#include "Derive.h"
-#import 
-@implementation DerivedInterface
-- (void)test {
-}
-@end


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


Re: [PATCH] D23079: ObjC: Use a new type for ObjC type parameter (patch 2 out of 3)

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

Hi Doug,

Can you take a look at the updated version?

Thanks,
Manman


https://reviews.llvm.org/D23079



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


r281119 - Modules: for ObjectiveC try to keep the definition invariant.

2016-09-09 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Sep  9 18:48:27 2016
New Revision: 281119

URL: http://llvm.org/viewvc/llvm-project?rev=281119&view=rev
Log:
Modules: for ObjectiveC try to keep the definition invariant.

When deserializing ObjCInterfaceDecl with definition data, if we already have
a definition, try to keep the definition invariant; also pull in the
categories even if it is not what getDefinition returns (this effectively
combines categories).

rdar://27926200
rdar://26708823

Added:
cfe/trunk/test/Modules/Inputs/lookup-assert/
cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
cfe/trunk/test/Modules/Inputs/objc-category/
cfe/trunk/test/Modules/Inputs/objc-category-2/
cfe/trunk/test/Modules/Inputs/objc-category-2/Base.h
cfe/trunk/test/Modules/Inputs/objc-category-2/Category.h
cfe/trunk/test/Modules/Inputs/objc-category-2/H3.h
cfe/trunk/test/Modules/Inputs/objc-category-2/module.map
cfe/trunk/test/Modules/Inputs/objc-category-3/
cfe/trunk/test/Modules/Inputs/objc-category-3/Base.h
cfe/trunk/test/Modules/Inputs/objc-category-3/Category.h
cfe/trunk/test/Modules/Inputs/objc-category-3/Category_B.h
cfe/trunk/test/Modules/Inputs/objc-category-3/H3.h
cfe/trunk/test/Modules/Inputs/objc-category-3/module.map
cfe/trunk/test/Modules/Inputs/objc-category/Base.h
cfe/trunk/test/Modules/Inputs/objc-category/Category.h
cfe/trunk/test/Modules/Inputs/objc-category/H3.h
cfe/trunk/test/Modules/Inputs/objc-category/module.map
cfe/trunk/test/Modules/lookup-assert.m
cfe/trunk/test/Modules/objc-category-2.m
cfe/trunk/test/Modules/objc-category-3.m
cfe/trunk/test/Modules/objc-category.m
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=281119&r1=281118&r2=281119&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Sep  9 18:48:27 2016
@@ -133,6 +133,10 @@ namespace clang {
const RecordData &R, unsigned &I);
 void MergeDefinitionData(CXXRecordDecl *D,
  struct CXXRecordDecl::DefinitionData &&NewDD);
+void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data,
+const RecordData &R, unsigned &I);
+void MergeDefinitionData(ObjCInterfaceDecl *D,
+ struct ObjCInterfaceDecl::DefinitionData &&NewDD);
 
 static NamedDecl *getAnonymousDeclForMerging(ASTReader &Reader,
  DeclContext *DC,
@@ -981,6 +985,43 @@ ObjCTypeParamList *ASTDeclReader::ReadOb
typeParams, rAngleLoc);
 }
 
+void ASTDeclReader::ReadObjCDefinitionData(
+ struct ObjCInterfaceDecl::DefinitionData &Data,
+ const RecordData &R, unsigned &I) {
+  // Read the superclass.
+  Data.SuperClassTInfo = GetTypeSourceInfo(Record, Idx);
+
+  Data.EndLoc = ReadSourceLocation(Record, Idx);
+  Data.HasDesignatedInitializers = Record[Idx++];
+   
+  // Read the directly referenced protocols and their SourceLocations.
+  unsigned NumProtocols = Record[Idx++];
+  SmallVector Protocols;
+  Protocols.reserve(NumProtocols);
+  for (unsigned I = 0; I != NumProtocols; ++I)
+Protocols.push_back(ReadDeclAs(Record, Idx));
+  SmallVector ProtoLocs;
+  ProtoLocs.reserve(NumProtocols);
+  for (unsigned I = 0; I != NumProtocols; ++I)
+ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
+  Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, 
ProtoLocs.data(),
+   Reader.getContext());
+ 
+  // Read the transitive closure of protocols referenced by this class.
+  NumProtocols = Record[Idx++];
+  Protocols.clear();
+  Protocols.reserve(NumProtocols);
+  for (unsigned I = 0; I != NumProtocols; ++I)
+Protocols.push_back(ReadDeclAs(Record, Idx));
+  Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
+  Reader.getContext());
+}
+
+void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
+ struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
+  // FIXME: odr checking?
+}
+
 void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
   RedeclarableResult Redecl = VisitRedeclarable(ID);
   VisitObjCContainerDecl(ID);
@@ -991,43 +1032,22 @@ void ASTDeclReader::VisitObjCInterfaceDe
   if (Record[Idx++]) {
 // Read the definition.
 ID->allocateDefinitionData();
-
-// Set the definition data of the canonical declaration, so other
-// redeclarations will see it.
-ID->getCanonicalDecl()->D

Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-09 Thread Manman Ren via cfe-commits
Committed r281119. Let me know if you see any problem.

Cheers,
Manman

On Fri, Sep 9, 2016 at 12:07 PM, Manman Ren  wrote:

>
>
> On Fri, Sep 9, 2016 at 11:33 AM, Richard Smith 
> wrote:
>
>> On Fri, Sep 9, 2016 at 11:29 AM, Manman Ren via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Wed, Sep 7, 2016 at 4:44 PM, Richard Smith 
>>> wrote:
>>>
>>>> On Wed, Sep 7, 2016 at 12:45 PM, Manman Ren 
>>>> wrote:
>>>>
>>>>> On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith 
>>>>> wrote:
>>>>>
>>>>>> On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
>>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>>
>>>>>>> Author: mren
>>>>>>> Date: Tue Sep  6 13:16:54 2016
>>>>>>> New Revision: 280728
>>>>>>>
>>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev
>>>>>>> Log:
>>>>>>> Modules: Fix an assertion in DeclContext::buildLookup.
>>>>>>>
>>>>>>> When calling getMostRecentDecl, we can pull in more definitions from
>>>>>>> a module. We call getPrimaryContext afterwards to make sure that
>>>>>>> we buildLookup on a primary context.
>>>>>>>
>>>>>>> rdar://27926200
>>>>>>>
>>>>>>> Added:
>>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/
>>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
>>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
>>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
>>>>>>> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
>>>>>>> cfe/trunk/test/Modules/lookup-assert.m
>>>>>>> Modified:
>>>>>>> cfe/trunk/lib/AST/DeclBase.cpp
>>>>>>>
>>>>>>> Modified: cfe/trunk/lib/AST/DeclBase.cpp
>>>>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
>>>>>>> se.cpp?rev=280728&r1=280727&r2=280728&view=diff
>>>>>>> 
>>>>>>> ==
>>>>>>> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
>>>>>>> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
>>>>>>> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>>>>>>>assert(DeclKind != Decl::LinkageSpec &&
>>>>>>>   "Should not perform lookups into linkage specs!");
>>>>>>>
>>>>>>> -  const DeclContext *PrimaryContext = getPrimaryContext();
>>>>>>> -  if (PrimaryContext != this)
>>>>>>> -return PrimaryContext->lookup(Name);
>>>>>>> -
>>>>>>>// If we have an external source, ensure that any later
>>>>>>> redeclarations of this
>>>>>>>// context have been loaded, since they may add names to the
>>>>>>> result of this
>>>>>>>// lookup (or add external visible storage).
>>>>>>> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>>>>>>>if (Source)
>>>>>>>  (void)cast(this)->getMostRecentDecl();
>>>>>>>
>>>>>>> +  // getMostRecentDecl can change the result of getPrimaryContext.
>>>>>>> Call
>>>>>>> +  // getPrimaryContext afterwards.
>>>>>>> +  const DeclContext *PrimaryContext = getPrimaryContext();
>>>>>>> +  if (PrimaryContext != this)
>>>>>>> +return PrimaryContext->lookup(Name);
>>>>>>>
>>>>>>
>>>>>> This seems like a bug in getPrimaryContext() -- if there is a
>>>>>> not-yet-loaded definition of the DeclContext, getPrimaryContext() should
>>>>>> return that instead of returning a non-defining declaration. Why is
>>>>>> ObjCInterfaceDecl::hasDefinition (indirectly called by
>>>>>> getPrimaryContext) not loading the definition in this case?
>>>>>>
>>>>>
>>>>> In the testing case, we have

r281351 - Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

2016-09-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep 13 11:45:29 2016
New Revision: 281351

URL: http://llvm.org/viewvc/llvm-project?rev=281351&view=rev
Log:
Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.

Now ObjCObjectType extends from ObjCProtocolQualifiers. We save number of
protocols in ObjCProtocolQualifiers.

This is in preparation of adding a new type class ObjCTypeParamType that
can take protocol qualifiers.

rdar://24619481
rdar://25060179

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

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=281351&r1=281350&r2=281351&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Sep 13 11:45:29 2016
@@ -4699,6 +4699,59 @@ public:
   }
 };
 
+/// This class wraps the list of protocol qualifiers. For types that can
+/// take ObjC protocol qualifers, they can subclass this class.
+template 
+class ObjCProtocolQualifiers {
+protected:
+  ObjCProtocolQualifiers() {}
+  ObjCProtocolDecl * const *getProtocolStorage() const {
+return const_cast(this)->getProtocolStorage();
+  }
+
+  ObjCProtocolDecl **getProtocolStorage() {
+return static_cast(this)->getProtocolStorageImpl();
+  }
+  void setNumProtocols(unsigned N) {
+static_cast(this)->setNumProtocolsImpl(N);
+  }
+  void initialize(ArrayRef protocols) {
+setNumProtocols(protocols.size());
+assert(getNumProtocols() == protocols.size() &&
+   "bitfield overflow in protocol count");
+if (!protocols.empty())
+  memcpy(getProtocolStorage(), protocols.data(),
+ protocols.size() * sizeof(ObjCProtocolDecl*));
+  }
+
+public:
+  typedef ObjCProtocolDecl * const *qual_iterator;
+  typedef llvm::iterator_range qual_range;
+
+  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
+  qual_iterator qual_begin() const { return getProtocolStorage(); }
+  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
+
+  bool qual_empty() const { return getNumProtocols() == 0; }
+
+  /// Return the number of qualifying protocols in this type, or 0 if
+  /// there are none.
+  unsigned getNumProtocols() const {
+return static_cast(this)->getNumProtocolsImpl();
+  }
+
+  /// Fetch a protocol by index.
+  ObjCProtocolDecl *getProtocol(unsigned I) const {
+assert(I < getNumProtocols() && "Out-of-range protocol access");
+return qual_begin()[I];
+  }
+
+  /// Retrieve all of the protocol qualifiers.
+  ArrayRef getProtocols() const {
+return ArrayRef(qual_begin(), getNumProtocols());
+  }
+};
+
 /// Represents a class type in Objective C.
 ///
 /// Every Objective C type is a combination of a base type, a set of
@@ -4727,7 +4780,9 @@ public:
 /// 'id' is an ObjCObjectPointerType whose pointee is an ObjCObjectType
 /// with base BuiltinType::ObjCIdType and protocol list [P].  Eventually
 /// this should get its own sugar class to better represent the source.
-class ObjCObjectType : public Type {
+class ObjCObjectType : public Type,
+   public ObjCProtocolQualifiers {
+  friend class ObjCProtocolQualifiers;
   // ObjCObjectType.NumTypeArgs - the number of type arguments stored
   // after the ObjCObjectPointerType node.
   // ObjCObjectType.NumProtocols - the number of protocols stored
@@ -4747,16 +4802,20 @@ class ObjCObjectType : public Type {
   mutable llvm::PointerIntPair
 CachedSuperClassType;
 
-  ObjCProtocolDecl * const *getProtocolStorage() const {
-return const_cast(this)->getProtocolStorage();
-  }
-
   QualType *getTypeArgStorage();
   const QualType *getTypeArgStorage() const {
 return const_cast(this)->getTypeArgStorage();
   }
 
-  ObjCProtocolDecl **getProtocolStorage();
+  ObjCProtocolDecl **getProtocolStorageImpl();
+  /// Return the number of qualifying protocols in this interface type,
+  /// or 0 if there are none.
+  unsigned getNumProtocolsImpl() const {
+return ObjCObjectTypeBits.NumProtocols;
+  }
+  void setNumProtocolsImpl(unsigned N) {
+ObjCObjectTypeBits.NumProtocols = N;
+  }
 
 protected:
   ObjCObjectType(QualType Canonical, QualType Base,
@@ -4833,30 +4892,6 @@ public:
   ObjCObjectTypeBits.NumTypeArgs);
   }
 
-  typedef ObjCProtocolDecl * const *qual_iterator;
-  typedef llvm::iterator_range qual_range;
-
-  qual_range quals() const { return qual_range(qual_begin(), qual_end()); }
-  qual_iterator qual_begin() const { return getProtocolStorage(); }
-  qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); }
-
-  bool qual_empty() const { return getNumProtocols() == 0; }
-
-  /// Return the number of qualifying protocols in this interface type,
-  /// or 0 if there are none.
-  unsigned getNumProtocols() const { return ObjCObjectTypeBi

r281353 - ObjectiveC: Refactor applyObjCProtocolQualifiers.

2016-09-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep 13 12:03:12 2016
New Revision: 281353

URL: http://llvm.org/viewvc/llvm-project?rev=281353&view=rev
Log:
ObjectiveC: Refactor applyObjCProtocolQualifiers.

To construct the canonical type of ObjCTypeParamType, we need to apply
qualifiers on ObjCObjectPointerType. The updated applyObjCProtocolQualifiers
handles this case by merging the protocol lists, constructing a new
ObjCObjectType, then a new ObjCObjectPointerType.

rdar://24619481
rdar://25060179

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=281353&r1=281352&r2=281353&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Sep 13 12:03:12 2016
@@ -1030,6 +1030,14 @@ public:
   /// replaced.
   QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const;
 
+  /// \brief Apply Objective-C protocol qualifiers to the given type.
+  /// \param allowOnPointerType specifies if we can apply protocol
+  /// qualifiers on ObjCObjectPointerType. It can be set to true when
+  /// contructing the canonical type of a Objective-C type parameter.
+  QualType applyObjCProtocolQualifiers(QualType type,
+  ArrayRef protocols, bool &hasError,
+  bool allowOnPointerType = false) const;
+
   /// \brief Return the uniqued reference to the type for an Objective-C
   /// gc-qualified type.
   ///

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=281353&r1=281352&r2=281353&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Sep 13 12:03:12 2016
@@ -3871,6 +3871,76 @@ QualType ASTContext::getObjCObjectType(
   return QualType(T, 0);
 }
 
+/// Apply Objective-C protocol qualifiers to the given type.
+/// If this is for the canonical type of a type parameter, we can apply
+/// protocol qualifiers on the ObjCObjectPointerType.
+QualType
+ASTContext::applyObjCProtocolQualifiers(QualType type,
+  ArrayRef protocols, bool &hasError,
+  bool allowOnPointerType) const {
+  hasError = false;
+
+  // Apply protocol qualifiers to ObjCObjectPointerType.
+  if (allowOnPointerType) {
+if (const ObjCObjectPointerType *objPtr =
+dyn_cast(type.getTypePtr())) {
+  const ObjCObjectType *objT = objPtr->getObjectType();
+  // Merge protocol lists and construct ObjCObjectType.
+  SmallVector protocolsVec;
+  protocolsVec.append(objT->qual_begin(),
+  objT->qual_end());
+  protocolsVec.append(protocols.begin(), protocols.end());
+  ArrayRef protocols = protocolsVec;
+  type = getObjCObjectType(
+ objT->getBaseType(),
+ objT->getTypeArgsAsWritten(),
+ protocols,
+ objT->isKindOfTypeAsWritten());
+  return getObjCObjectPointerType(type);
+}
+  }
+
+  // Apply protocol qualifiers to ObjCObjectType.
+  if (const ObjCObjectType *objT = 
dyn_cast(type.getTypePtr())){
+// FIXME: Check for protocols to which the class type is already
+// known to conform.
+
+return getObjCObjectType(objT->getBaseType(),
+ objT->getTypeArgsAsWritten(),
+ protocols,
+ objT->isKindOfTypeAsWritten());
+  }
+
+  // If the canonical type is ObjCObjectType, ...
+  if (type->isObjCObjectType()) {
+// Silently overwrite any existing protocol qualifiers.
+// TODO: determine whether that's the right thing to do.
+
+// FIXME: Check for protocols to which the class type is already
+// known to conform.
+return getObjCObjectType(type, { }, protocols, false);
+  }
+
+  // id
+  if (type->isObjCIdType()) {
+const ObjCObjectPointerType *objPtr = 
type->castAs();
+type = getObjCObjectType(ObjCBuiltinIdTy, { }, protocols,
+ objPtr->isKindOfType());
+return getObjCObjectPointerType(type);
+  }
+
+  // Class
+  if (type->isObjCClassType()) {
+const ObjCObjectPointerType *objPtr = 
type->castAs();
+type = getObjCObjectType(ObjCBuiltinClassTy, { }, protocols,
+ objPtr->isKindOfType());
+return getObjCObjectPointerType(type);
+  }
+
+  hasError = true;
+  return type;
+}
+
 /// ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's
 /// protocol list adopt all protocols in QT's qualified-id protocol
 /// list.

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=281353&r1=281352

r281355 - ObjectiveC generics: Add ObjCTypeParamType in the type system.

2016-09-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep 13 12:25:08 2016
New Revision: 281355

URL: http://llvm.org/viewvc/llvm-project?rev=281355&view=rev
Log:
ObjectiveC generics: Add ObjCTypeParamType in the type system.

We also need to add ObjCTypeParamTypeLoc. ObjCTypeParamType supports the
representation of "T " where T is a type parameter. Before this,
we use TypedefType to represent the type parameter for ObjC.

ObjCTypeParamType has "ObjCTypeParamDecl *OTPDecl" and it extends from
ObjCProtocolQualifiers. It is a non-canonical type and is canonicalized
to the underlying type with the protocol qualifiers.

rdar://24619481
rdar://25060179

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/AST/TypeNodes.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=281355&r1=281354&r2=281355&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Sep 13 12:25:08 2016
@@ -114,6 +114,7 @@ class ASTContext : public RefCountedBase
   mutable llvm::FoldingSet DependentTypeOfExprTypes;
   mutable llvm::FoldingSet DependentDecltypeTypes;
   mutable llvm::FoldingSet TemplateTypeParmTypes;
+  mutable llvm::FoldingSet ObjCTypeParamTypes;
   mutable llvm::FoldingSet
 SubstTemplateTypeParmTypes;
   mutable llvm::FoldingSet
@@ -1328,6 +1329,10 @@ public:
  ArrayRef typeArgs,
  ArrayRef protocols,
  bool isKindOf) const;
+
+  QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl,
+ArrayRef protocols,
+QualType Canonical = QualType()) const;
   
   bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl);
   /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=281355&r1=281354&r2=281355&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Sep 13 12:25:08 2016
@@ -1044,6 +1044,8 @@ DEF_TRAVERSE_TYPE(DependentTemplateSpeci
 
 DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); 
})
 
+DEF_TRAVERSE_TYPE(ObjCTypeParamType, {})
+
 DEF_TRAVERSE_TYPE(ObjCInterfaceType, {})
 
 DEF_TRAVERSE_TYPE(ObjCObjectType, {
@@ -1275,6 +1277,8 @@ DEF_TRAVERSE_TYPELOC(DependentTemplateSp
 DEF_TRAVERSE_TYPELOC(PackExpansionType,
  { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
 
+DEF_TRAVERSE_TYPELOC(ObjCTypeParamType, {})
+
 DEF_TRAVERSE_TYPELOC(ObjCInterfaceType, {})
 
 DEF_TRAVERSE_TYPELOC(ObjCObjectType, {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=281355&r1=281354&r2=281355&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Sep 13 12:25:08 2016
@@ -88,6 +88,7 @@ namespace clang {
   class ObjCInterfaceDecl;
   class ObjCProtocolDecl;
   class ObjCMethodDecl;
+  class ObjCTypeParamDecl;
   class UnresolvedUsingTypenameDecl;
   class Expr;
   class Stmt;
@@ -4752,6 +4753,49 @@ public:
   }
 };
 
+/// Represents a type parameter type in Objective C. It can take
+/// a list of protocols.
+class ObjCTypeParamType : public Type,
+  public ObjCProtocolQualifiers,
+  public llvm::FoldingSetNode {
+  friend class ASTContext;
+  friend class ObjCProtocolQualifiers;
+
+  /// The number of protocols stored on this type.
+  unsigned NumProtocols : 6;
+
+  ObjCTypeParamDecl *OTPDecl;
+  /// The protocols are stored after the ObjCTypeParamType node. In the
+  /// canonic

r281358 - ObjectiveC Generics: Start using ObjCTypeParamType.

2016-09-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep 13 12:41:05 2016
New Revision: 281358

URL: http://llvm.org/viewvc/llvm-project?rev=281358&view=rev
Log:
ObjectiveC Generics: Start using ObjCTypeParamType.

For ObjC type parameter, we used to have TypedefType that is canonicalized to
id or the bound type. We can't represent "T " and thus will lose
the type information in the following example:
@interface MyMutableDictionary : NSObject
- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType )key;
@end
MyMutableDictionary *stringsByString;
NSNumber *n1, *n2;
stringsByString[n1] = n2;
--> no warning on type mismatch of the key.

To fix the problem, we introduce a new type ObjCTypeParamType that supports
a list of protocol qualifiers.

We create ObjCTypeParamType for ObjCTypeParamDecl when we create
ObjCTypeParamDecl. We also substitute ObjCTypeParamType instead of TypedefType
on an ObjCTypeParamDecl.

rdar://24619481
rdar://25060179

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

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/test/SemaObjC/kindof.m
cfe/trunk/test/SemaObjC/parameterized_classes_subst.m

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=281358&r1=281357&r2=281358&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Sep 13 12:41:05 2016
@@ -3883,6 +3883,11 @@ ASTContext::applyObjCProtocolQualifiers(
   bool allowOnPointerType) const {
   hasError = false;
 
+  if (const ObjCTypeParamType *objT =
+  dyn_cast(type.getTypePtr())) {
+return getObjCTypeParamType(objT->getDecl(), protocols);
+  }
+
   // Apply protocol qualifiers to ObjCObjectPointerType.
   if (allowOnPointerType) {
 if (const ObjCObjectPointerType *objPtr =

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=281358&r1=281357&r2=281358&view=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Tue Sep 13 12:41:05 2016
@@ -1320,8 +1320,12 @@ ObjCTypeParamDecl *ObjCTypeParamDecl::Cr
  IdentifierInfo *name,
  SourceLocation colonLoc,
  TypeSourceInfo *boundInfo) {
-  return new (ctx, dc) ObjCTypeParamDecl(ctx, dc, variance, varianceLoc, index,
- nameLoc, name, colonLoc, boundInfo);
+  auto *TPDecl =
+new (ctx, dc) ObjCTypeParamDecl(ctx, dc, variance, varianceLoc, index,
+nameLoc, name, colonLoc, boundInfo);
+  QualType TPType = ctx.getObjCTypeParamType(TPDecl, {});
+  TPDecl->setTypeForDecl(TPType.getTypePtr());
+  return TPDecl;
 }
 
 ObjCTypeParamDecl *ObjCTypeParamDecl::CreateDeserialized(ASTContext &ctx,

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=281358&r1=281357&r2=281358&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Sep 13 12:41:05 2016
@@ -1081,13 +1081,24 @@ QualType QualType::substObjCTypeArgs(
 
 // Replace an Objective-C type parameter reference with the corresponding
 // type argument.
-if (const auto *typedefTy = dyn_cast(splitType.Ty)) {
-  if (auto *typeParam = dyn_cast(typedefTy->getDecl())) 
{
+if (const auto *OTPTy = dyn_cast(splitType.Ty)) {
+  if (auto *typeParam = dyn_cast(OTPTy->getDecl())) {
 // If we have type arguments, use them.
 if (!typeArgs.empty()) {
-  // FIXME: Introduce SubstObjCTypeParamType ?
   QualType argType = typeArgs[typeParam->getIndex()];
-  return ctx.getQualifiedType(argType, splitType.Quals);
+  if (OTPTy->qual_empty())
+return ctx.getQualifiedType(argType, splitType.Quals);
+
+  // Apply protocol lists if exists.
+  bool hasError;
+  SmallVector protocolsVec;
+  protocolsVec.append(OTPTy->qual_begin(),
+  OTPTy->qual_end());
+  ArrayRef protocolsToApply = protocolsVec;
+  QualType resultTy = ctx.applyObjCProtocolQualifiers(argType,
+  protocolsToApply, hasError, true/*allowOnPointerType*/);
+
+  return ctx.getQualifiedType(resultTy, splitType.Quals);
 }
 
 switch (context) {

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.c

r281404 - ObjectiveC Generics: follow-up commit to r281355.

2016-09-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep 13 16:57:28 2016
New Revision: 281404

URL: http://llvm.org/viewvc/llvm-project?rev=281404&view=rev
Log:
ObjectiveC Generics: follow-up commit to r281355.

Correct getExtraLocalDataSize for ObjCTypeParamTypeLoc.

rdar://24619481
rdar://25060179

Modified:
cfe/trunk/include/clang/AST/TypeLoc.h

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=281404&r1=281403&r2=281404&view=diff
==
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Tue Sep 13 16:57:28 2016
@@ -763,7 +763,9 @@ public:
 
   unsigned getExtraLocalDataSize() const {
 if (!this->getNumProtocols()) return 0;
-return this->getNumProtocols() * sizeof(SourceLocation) ;
+// When there are protocol qualifers, we have LAngleLoc and RAngleLoc
+// as well.
+return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ;
   }
   unsigned getExtraLocalDataAlignment() const {
 return llvm::alignOf();


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


r292508 - Module: Improve diagnostic message when cxx modules are disabled and @import is used in Objective CXX.

2017-01-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Jan 19 13:05:55 2017
New Revision: 292508

URL: http://llvm.org/viewvc/llvm-project?rev=292508&view=rev
Log:
Module: Improve diagnostic message when cxx modules are disabled and @import is 
used in Objective CXX.

rdar://problem/19399671

Added:
cfe/trunk/test/Modules/check-syntax.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=292508&r1=292507&r2=292508&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jan 19 13:05:55 
2017
@@ -243,7 +243,10 @@ def err_expected_property_name : Error<"
 
 def err_unexpected_at : Error<"unexpected '@' in program">;
 def err_atimport : Error<
-"use of '@import' when modules are disabled">;
+  "use of '@import' when modules are disabled">;
+def err_atimport_cxx : Error<
+  "use of '@import' when C++ modules are disabled, consider using fmodules "
+  "and fcxx-modules">;
 
 def err_invalid_reference_qualifier_application : Error<
   "'%0' qualifier may not be applied to a reference">;

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=292508&r1=292507&r2=292508&view=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jan 19 13:05:55 2017
@@ -83,7 +83,10 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
   case tok::objc_import:
 if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
   return ParseModuleImport(AtLoc);
-Diag(AtLoc, diag::err_atimport);
+if (getLangOpts().CPlusPlus)
+  Diag(AtLoc, diag::err_atimport_cxx);
+else
+  Diag(AtLoc, diag::err_atimport);
 SkipUntil(tok::semi);
 return Actions.ConvertDeclToDeclGroup(nullptr);
   default:

Added: cfe/trunk/test/Modules/check-syntax.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/check-syntax.mm?rev=292508&view=auto
==
--- cfe/trunk/test/Modules/check-syntax.mm (added)
+++ cfe/trunk/test/Modules/check-syntax.mm Thu Jan 19 13:05:55 2017
@@ -0,0 +1,5 @@
+// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 | 
FileCheck %s
+// rdar://19399671
+
+// CHECK: use of '@import' when C++ modules are disabled
+@import Foundation;


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


Re: r292508 - Module: Improve diagnostic message when cxx modules are disabled and @import is used in Objective CXX.

2017-01-20 Thread Manman Ren via cfe-commits
On Thu, Jan 19, 2017 at 1:27 PM, Richard Smith 
wrote:

> On 19 Jan 2017 11:16 am, "Manman Ren via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: mren
> Date: Thu Jan 19 13:05:55 2017
> New Revision: 292508
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292508&view=rev
> Log:
> Module: Improve diagnostic message when cxx modules are disabled and
> @import is used in Objective CXX.
>
> rdar://problem/19399671
>
> Added:
> cfe/trunk/test/Modules/check-syntax.mm
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> cfe/trunk/lib/Parse/ParseObjc.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Basic/DiagnosticParseKinds.td?rev=292508&r1=292507&r2=292508&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jan 19
> 13:05:55 2017
> @@ -243,7 +243,10 @@ def err_expected_property_name : Error<"
>
>  def err_unexpected_at : Error<"unexpected '@' in program">;
>  def err_atimport : Error<
> -"use of '@import' when modules are disabled">;
> +  "use of '@import' when modules are disabled">;
> +def err_atimport_cxx : Error<
> +  "use of '@import' when C++ modules are disabled, consider using
> fmodules "
> +  "and fcxx-modules">;
>
>
> Please add a hyphen before fmodules. There's also no reason to suggest
> -fcxx-modules; modules support for C++ is controlled by -fmodules nowadays.
>
> I also don't think it makes sense to have different diagnostics for C and
> C++ mode; we should suggest the -fmodules flag in either case.
>

Hi Richard,

This is an internal patch that I am upstreaming to open source. Internally
at Apple, modules support for C++ is off by default, users need to use
-fcxx-modules to turn it on. So when they use -fmodules without
-fcxx-modules, they will get a confusing error saying modules are disabled.

Open source, the testing case in this commit uses driver option
-fno-cxx-modules, in this case, it makes sense to call out c++ modules so
users know to remove -fno-cxx-modules.

Let me know your thoughts,
Manman


>
>  def err_invalid_reference_qualifier_application : Error<
>"'%0' qualifier may not be applied to a reference">;
>
> Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Pars
> eObjc.cpp?rev=292508&r1=292507&r2=292508&view=diff
> 
> ==
> --- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jan 19 13:05:55 2017
> @@ -83,7 +83,10 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
>case tok::objc_import:
>  if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
>return ParseModuleImport(AtLoc);
> -Diag(AtLoc, diag::err_atimport);
> +if (getLangOpts().CPlusPlus)
> +  Diag(AtLoc, diag::err_atimport_cxx);
> +else
> +  Diag(AtLoc, diag::err_atimport);
>  SkipUntil(tok::semi);
>  return Actions.ConvertDeclToDeclGroup(nullptr);
>default:
>
> Added: cfe/trunk/test/Modules/check-syntax.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/
> check-syntax.mm?rev=292508&view=auto
> 
> ==
> --- cfe/trunk/test/Modules/check-syntax.mm (added)
> +++ cfe/trunk/test/Modules/check-syntax.mm Thu Jan 19 13:05:55 2017
> @@ -0,0 +1,5 @@
> +// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 |
> FileCheck %s
> +// rdar://19399671
> +
> +// CHECK: use of '@import' when C++ modules are disabled
> +@import Foundation;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292639 - Revert r292508 given that we intend to remove driver options for cxx modules.

2017-01-20 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Jan 20 14:03:00 2017
New Revision: 292639

URL: http://llvm.org/viewvc/llvm-project?rev=292639&view=rev
Log:
Revert r292508 given that we intend to remove driver options for cxx modules.

Removed:
cfe/trunk/test/Modules/check-syntax.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=292639&r1=292638&r2=292639&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Jan 20 14:03:00 
2017
@@ -243,10 +243,7 @@ def err_expected_property_name : Error<"
 
 def err_unexpected_at : Error<"unexpected '@' in program">;
 def err_atimport : Error<
-  "use of '@import' when modules are disabled">;
-def err_atimport_cxx : Error<
-  "use of '@import' when C++ modules are disabled, consider using fmodules "
-  "and fcxx-modules">;
+"use of '@import' when modules are disabled">;
 
 def err_invalid_reference_qualifier_application : Error<
   "'%0' qualifier may not be applied to a reference">;

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=292639&r1=292638&r2=292639&view=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Jan 20 14:03:00 2017
@@ -83,10 +83,7 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
   case tok::objc_import:
 if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
   return ParseModuleImport(AtLoc);
-if (getLangOpts().CPlusPlus)
-  Diag(AtLoc, diag::err_atimport_cxx);
-else
-  Diag(AtLoc, diag::err_atimport);
+Diag(AtLoc, diag::err_atimport);
 SkipUntil(tok::semi);
 return Actions.ConvertDeclToDeclGroup(nullptr);
   default:

Removed: cfe/trunk/test/Modules/check-syntax.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/check-syntax.mm?rev=292638&view=auto
==
--- cfe/trunk/test/Modules/check-syntax.mm (original)
+++ cfe/trunk/test/Modules/check-syntax.mm (removed)
@@ -1,5 +0,0 @@
-// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 | 
FileCheck %s
-// rdar://19399671
-
-// CHECK: use of '@import' when C++ modules are disabled
-@import Foundation;


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


[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-11-14 Thread Manman Ren via cfe-commits
manmanren added a comment.

@ Ben,

We are hitting this issue when building large projects, but the reproducibility 
is quite low.

This proposed patch is currently a little too complicated. I am thinking about 
just fixing the testing case for now, and adding the check later when we start 
to share some data structures between threads (the idea of keeping MemoryBuffer 
consistent for threads within a single clang invocation).

For this testing case, we ignore the diagnostic options when a module is 
imported by a system module (see the code snippet below):

  ModuleFile *TopImport = *ModuleMgr.rbegin();
  while (!TopImport->ImportedBy.empty())
TopImport = TopImport->ImportedBy[0];
  if (TopImport->Kind != MK_ImplicitModule)
return false;
  
  StringRef ModuleName = TopImport->ModuleName;
  assert(!ModuleName.empty() && "diagnostic options read before module name");
  
  Module *M = PP.getHeaderSearchInfo().lookupModule(ModuleName);
  assert(M && "missing module");
  
  // FIXME: if the diagnostics are incompatible, save a DiagnosticOptions that
  // contains the union of their flags.
  return checkDiagnosticMappings(*Diags, ExistingDiags, M->IsSystem, Complain);

And here

  // If we're reading the first module for this group, check its options
  // are compatible with ours. For modules it imports, no further checking
  // is required, because we checked them when we built it.
  if (Listener && !ImportedBy) {

Does it mean that a system module should only import system modules? If a 
system module is allowed to import non-system modules, for a non-system module, 
we will validate diagnostic options differently depending on whether a system 
module or a non-system module imports it. This will cause a non-system module 
that was validated earlier to be invalidated by a child thread.

Thanks,
Manman


https://reviews.llvm.org/D25916



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


[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-11-14 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D25916#594844, @benlangmuir wrote:

> > Does it mean that a system module should only import system modules? If a 
> > system module is allowed to import non-system modules, for a non-system 
> > module, we will validate diagnostic options differently depending on 
> > whether a system module or a non-system module imports it. This will cause 
> > a non-system module that was validated earlier to be invalidated by a child 
> > thread.
>
> It seems like we should validate the options the same way regardless of what 
> the importer is, but I'm guessing this was done for a reason... What's the 
> behaviour of a user-header imported by a system header (without modules)?  If 
> the user header warnings show up even without -Wsystem-headers, then we 
> should be okay validating, right?


I tried a simple example:
cat test.mm 
#include "a.h"
cat Inputs/System/a.h 
#include "b.h"
cat Inputs/b.h 
void double_declarator1(int *_Nonnull *); // expected-warning{{pointer is 
missing a nullability type specifier (_Nonnull, _Nullable, or 
_Null_unspecified)}}

clang -cc1 -fsyntax-only -fblocks -I Inputs/ -isystem Inputs/System/ test.mm
--> has no warning
~/llvm_gmail/debug/bin/clang -cc1 -fsyntax-only -fblocks -I Inputs/ -isystem 
Inputs/System/ test.mm -Wsystem-headers
--> has one warning

Without modules, the user header warnings do not show up if it is included by a 
system header (without -Wsystem-headers). To exactly match this behavior, user 
modules need to be validated considering the importing context. We will need to 
change the code snippets I mentioned earlier to re-validate the options when 
the importing context changes.

Thanks,
Manman


https://reviews.llvm.org/D25916



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


[PATCH] D26503: [Parser][ObjC] Improve diagnostics and recovery when C++ keywords are used as identifiers in Objective-C++

2016-11-15 Thread Manman Ren via cfe-commits
manmanren added a comment.

Cheers,
Manman




Comment at: include/clang/Basic/DiagnosticParseKinds.td:442
+/// Objective-C++ parser diagnostics
+def err_expected_objcxx_keyword : Error<
+  "expected %0; %1 is a keyword in Objective-C++">;

This name is a little misleading. It sounds like we are expecting a keyword :]



Comment at: include/clang/Parse/Parser.h:798
+  ///
+  /// Try to recover from the error by checking if the next token if a C++
+  /// keyword when parsing Objective-C++. Return false if the recovery was

--> if the next token is a C++ (if to is)



Comment at: include/clang/Parse/Parser.h:801
+  /// successful.
+  bool diagnoseExpectedObjCIdentifier();
+

Same here. The function name is kind of misleading.



Comment at: lib/Parse/ParseDecl.cpp:5405
+  // Objective-C++: Detect C++ keywords and try to prevent further errors 
by
+  // treating these keyword as valid member names.
+  if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus &&

Does C++ have the same issue? Or is this only needed for Objective-C++?



Comment at: lib/Parse/ParseObjc.cpp:153
 MaybeSkipAttributes(tok::objc_class);
-if (Tok.isNot(tok::identifier)) {
-  Diag(Tok, diag::err_expected) << tok::identifier;
+if (Tok.isNot(tok::identifier) && diagnoseExpectedObjCIdentifier()) {
   SkipUntil(tok::semi);

Are we doing this for all occurrences of "isNot(token::identifier)"?
Is it better to wrap this "&&" in the function and rename the function to 
something like diagnoseNonIdentifier?


Repository:
  rL LLVM

https://reviews.llvm.org/D26503



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


r287244 - ObjC Module: try to make objc module deterministic.

2016-11-17 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Nov 17 12:41:18 2016
New Revision: 287244

URL: http://llvm.org/viewvc/llvm-project?rev=287244&view=rev
Log:
ObjC Module: try to make objc module deterministic.

Make sure that comparing selectors in DeclarationName does its job.
rdar://problem/28988750

Added:
cfe/trunk/test/Modules/stress-objc.m
Modified:
cfe/trunk/lib/AST/DeclarationName.cpp

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=287244&r1=287243&r2=287244&view=diff
==
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Thu Nov 17 12:41:18 2016
@@ -95,12 +95,18 @@ int DeclarationName::compare(Declaration
   case DeclarationName::ObjCMultiArgSelector: {
 Selector LHSSelector = LHS.getObjCSelector();
 Selector RHSSelector = RHS.getObjCSelector();
+// getNumArgs for ZeroArgSelector returns 0, but we still need to compare.
+if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector &&
+RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector) {
+  return LHSSelector.getAsIdentifierInfo()->getName().compare(
+ RHSSelector.getAsIdentifierInfo()->getName());
+}
 unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
 for (unsigned I = 0, N = std::min(LN, RN); I != N; ++I) {
   switch (LHSSelector.getNameForSlot(I).compare(
RHSSelector.getNameForSlot(I))) 
{
-  case -1: return true;
-  case 1: return false;
+  case -1: return -1;
+  case 1: return 1;
   default: break;
   }
 }

Added: cfe/trunk/test/Modules/stress-objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/stress-objc.m?rev=287244&view=auto
==
--- cfe/trunk/test/Modules/stress-objc.m (added)
+++ cfe/trunk/test/Modules/stress-objc.m Thu Nov 17 12:41:18 2016
@@ -0,0 +1,22 @@
+// RUN: cd %S
+
+// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00.pch 
-fno-pch-timestamp
+// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_1.pch 
-fno-pch-timestamp
+// RUN: diff %t_c00.pch %t_c00_1.pch
+
+// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_2.pch 
-fno-pch-timestamp
+// RUN: diff %t_c00.pch %t_c00_2.pch
+
+// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_3.pch 
-fno-pch-timestamp
+// RUN: diff %t_c00.pch %t_c00_3.pch
+
+// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_4.pch 
-fno-pch-timestamp
+// RUN: diff %t_c00.pch %t_c00_4.pch
+
+// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_5.pch 
-fno-pch-timestamp
+// RUN: diff %t_c00.pch %t_c00_5.pch
+
+@protocol NSObject
+- (void)doesNotRecognizeSelector:(SEL)aSelector;
+- (id)forwardingTargetForSelector:(SEL)aSelector;
+@end


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


[PATCH] D25284: AvailabilityAttrs: Delay partial availability diagnostics

2016-10-17 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

This is better than what I asked for :]

Manman


https://reviews.llvm.org/D25284



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


[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-17 Thread Manman Ren via cfe-commits
manmanren added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:10129
+!Var->isThisDeclarationADemotedDefinition()) {
+  assert(Var->isThisDeclarationADemotedDefinition() && 
getLangOpts().Modules
+ && "Demoting decls is only in the contest of modules!");

Is the logic correct here? The if statement says 
!Var->isThisDeclarationADemotedDefinition(), and we then assert 
Var->isThisDeclarationADemotedDefinition() && getLangOpts().Modules.


Repository:
  rL LLVM

https://reviews.llvm.org/D25678



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


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

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

Thanks a lot for the pointers!

I will definitely try them. What I proposed here is something similar to what 
llvm does that dumps logging messages, it should be complementary to your 
debugging aids.

Manman

In https://reviews.llvm.org/D22638#572753, @v.g.vassilev wrote:

> I am not sure whether that's useful for debugging out-of-date issues but this 
> is what I use and it is helpful.
>
> Some debugging aids (suggested by Richard Smith):
>
>   -fdiagnostics-show-note-include-stack will tell you which module a note 
> comes from
>   #pragma clang __debug dump X allows you to produce an AST dump from within 
> a source file, so you can see which modules declare a given name
>   #pragma clang __debug macro M allows you to dump a macro, which can be 
> useful to see which module(s) export visible include guards for a header
>   
>
> If a name is not visible in a modules build but is visible in a non-modules 
> build, i usually find that's due to one of two things
>
>   some part of the machinery that provides it depends on macro definitions 
> leaking into a modular header from outside, or
>   there is an include cycle involving a modular header and a non-modular 
> header



https://reviews.llvm.org/D22638



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


[PATCH] D25777: [Sema][TreeTransform] Re-create DesignatedInitExpr when it has a field designator with a valid FieldDecl

2016-10-19 Thread Manman Ren via cfe-commits
manmanren added a comment.

It makes sense to rebuild the expression when a field designator stores a 
FieldDecl.

Thanks for working on this!
Manman




Comment at: lib/Sema/TreeTransform.h:8926
D.getFieldLoc()));
+  if (D.getField())
+ExprChanged = true;

Please add comment here on why we need to set ExprChanged to true.


Repository:
  rL LLVM

https://reviews.llvm.org/D25777



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


[PATCH] D25806: Module: correctly set the module file kind when emitting diagnostics for file_modified

2016-10-19 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: bruno, rsmith, benlangmuir.
manmanren added a subscriber: cfe-commits.

I don't quite like the if statement in the patch, but given that 
ASTReader::Error and DelayedDiagnostic only take strings, it is hard to just 
change err_fe_pch_file_modified to take a %select that depends on an integer.

On the other hard, it seems impossible to have another diagnostics in flight 
when emitting err_fe_pch_file_modified. Is it okay to just use Diag instead of 
Error?

Unfortunately I was not able to come up with a test that outputs this 
diagnostics for a module file.


https://reviews.llvm.org/D25806

Files:
  include/clang/Basic/DiagnosticSerializationKinds.td
  lib/Serialization/ASTReader.cpp


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1983,6 +1983,7 @@
   return R;
 }
 
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // If this ID is bogus, just return an empty input file.
   if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  unsigned DiagnosticKind = 
moduleKindForDiagnostic(ImportStack.back()->Kind);
+  if (DiagnosticKind == 0)
+Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  else if (DiagnosticKind == 1)
+Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+  else
+Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
 
   // Print the import stack.
   if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
Index: include/clang/Basic/DiagnosticSerializationKinds.td
===
--- include/clang/Basic/DiagnosticSerializationKinds.td
+++ include/clang/Basic/DiagnosticSerializationKinds.td
@@ -21,6 +21,12 @@
 def err_fe_pch_file_modified : Error<
 "file '%0' has been modified since the precompiled header '%1' was built">,
 DefaultFatal;
+def err_fe_module_file_modified : Error<
+"file '%0' has been modified since the module file '%1' was built">,
+DefaultFatal;
+def err_fe_ast_file_modified : Error<
+"file '%0' has been modified since the AST file '%1' was built">,
+DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
 def note_pch_required_by : Note<"'%0' required by '%1'">;


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1983,6 +1983,7 @@
   return R;
 }
 
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // If this ID is bogus, just return an empty input file.
   if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  unsigned DiagnosticKind = moduleKindForDiagnostic(ImportStack.back()->Kind);
+  if (DiagnosticKind == 0)
+Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  else if (DiagnosticKind == 1)
+Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+  else
+Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
 
   // Print the import stack.
   if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
Index: include/clang/Basic/DiagnosticSerializationKinds.td
===
--- include/clang/Basic/DiagnosticSerializationKinds.td
+++ include/clang/Basic/DiagnosticSerializationKinds.td
@@ -21,6 +21,12 @@
 def err_fe_pch_file_modified : Error<
 "file '%0' has been modified since the precompiled header '%1' was built">,
 DefaultFatal;
+def err_fe_module_file_modified : Error<
+"file '%0' has been modified since the module file '%1' was built">,
+DefaultFatal;
+def err_fe_ast_file_modified : Error<
+"file '%0' has been modified since the AST file '%1' was built">,
+DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
 def note_pch_required_by : Note<"'%0' required by '%1'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25806: Module: correctly set the module file kind when emitting diagnostics for file_modified

2016-10-20 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 75326.
manmanren added a comment.

Thanks Richard for the testing case. It is also obvious from the testing case 
that we can have another diagnostic in flight when emitting 
err_fe_pch_file_modified.


https://reviews.llvm.org/D25806

Files:
  include/clang/Basic/DiagnosticSerializationKinds.td
  lib/Serialization/ASTReader.cpp
  test/Modules/module-file-modified.c


Index: test/Modules/module-file-modified.c
===
--- test/Modules/module-file-modified.c
+++ test/Modules/module-file-modified.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'int foo = 0;' > %t/a.h
+// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap
+// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap 
-o %t/m.pcm
+// RUN: echo 'int bar;' > %t/a.h
+// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm 
-fmodule-map-file=%t/m.modulemap -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s
+#include "a.h"
+int foo = 0; // redefinition of 'foo'
+// CHECK: fatal error: file {{.*}} has been modified since the module file 
{{.*}} was built
+// REQUIRES: shell
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1983,6 +1983,7 @@
   return R;
 }
 
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // If this ID is bogus, just return an empty input file.
   if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  unsigned DiagnosticKind = 
moduleKindForDiagnostic(ImportStack.back()->Kind);
+  if (DiagnosticKind == 0)
+Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  else if (DiagnosticKind == 1)
+Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+  else
+Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
 
   // Print the import stack.
   if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
Index: include/clang/Basic/DiagnosticSerializationKinds.td
===
--- include/clang/Basic/DiagnosticSerializationKinds.td
+++ include/clang/Basic/DiagnosticSerializationKinds.td
@@ -21,6 +21,12 @@
 def err_fe_pch_file_modified : Error<
 "file '%0' has been modified since the precompiled header '%1' was built">,
 DefaultFatal;
+def err_fe_module_file_modified : Error<
+"file '%0' has been modified since the module file '%1' was built">,
+DefaultFatal;
+def err_fe_ast_file_modified : Error<
+"file '%0' has been modified since the AST file '%1' was built">,
+DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
 def note_pch_required_by : Note<"'%0' required by '%1'">;


Index: test/Modules/module-file-modified.c
===
--- test/Modules/module-file-modified.c
+++ test/Modules/module-file-modified.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'int foo = 0;' > %t/a.h
+// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap
+// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap -o %t/m.pcm
+// RUN: echo 'int bar;' > %t/a.h
+// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm -fmodule-map-file=%t/m.modulemap -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s
+#include "a.h"
+int foo = 0; // redefinition of 'foo'
+// CHECK: fatal error: file {{.*}} has been modified since the module file {{.*}} was built
+// REQUIRES: shell
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1983,6 +1983,7 @@
   return R;
 }
 
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // If this ID is bogus, just return an empty input file.
   if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  unsigned DiagnosticKind = moduleKindForDiagnostic(ImportStack.back()->Kind);
+  if (DiagnosticKind == 0)
+Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  else if (DiagnosticKind == 1)
+Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+  else
+Error(diag::err_fe_ast_file_modified, Filename, 

r284897 - Module: improve the diagnostic message for include of non-modular header.

2016-10-21 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Oct 21 18:27:37 2016
New Revision: 284897

URL: http://llvm.org/viewvc/llvm-project?rev=284897&view=rev
Log:
Module: improve the diagnostic message for include of non-modular header.

Emit the actual path to the non-modular include.

rdar://28897010

Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/incomplete-module.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=284897&r1=284896&r2=284897&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Oct 21 18:27:37 2016
@@ -659,10 +659,10 @@ def warn_use_of_private_header_outside_m
 def err_undeclared_use_of_module : Error<
   "module %0 does not depend on a module exporting '%1'">;
 def warn_non_modular_include_in_framework_module : Warning<
-  "include of non-modular header inside framework module '%0'">,
+  "include of non-modular header inside framework module '%0': '%1'">,
   InGroup, DefaultIgnore;
 def warn_non_modular_include_in_module : Warning<
-  "include of non-modular header inside module '%0'">,
+  "include of non-modular header inside module '%0': '%1'">,
   InGroup, DefaultIgnore;
 def warn_module_conflict : Warning<
   "module '%0' conflicts with already-imported module '%1': %2">, 

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=284897&r1=284896&r2=284897&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Oct 21 18:27:37 2016
@@ -303,7 +303,8 @@ void ModuleMap::diagnoseHeaderInclusion(
 diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ?
 diag::warn_non_modular_include_in_framework_module :
 diag::warn_non_modular_include_in_module;
-Diags.Report(FilenameLoc, DiagID) << RequestingModule->getFullModuleName();
+Diags.Report(FilenameLoc, DiagID) << RequestingModule->getFullModuleName()
+<< File->getName();
   }
 }
 

Modified: cfe/trunk/test/Modules/incomplete-module.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/incomplete-module.m?rev=284897&r1=284896&r2=284897&view=diff
==
--- cfe/trunk/test/Modules/incomplete-module.m (original)
+++ cfe/trunk/test/Modules/incomplete-module.m Fri Oct 21 18:27:37 2016
@@ -2,7 +2,7 @@
 
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules-cache-path=%t -Wincomplete-module -fmodules 
-fimplicit-module-maps -I %S/Inputs %s 2>&1 | FileCheck %s
-// CHECK: warning: include of non-modular header inside module 'incomplete_mod'
+// CHECK: warning: include of non-modular header inside module 
'incomplete_mod': {{'.*incomplete_mod_missing.h'}}
 
 // RUN: rm -rf %t
 // RUN: not %clang_cc1 -fmodules-cache-path=%t -fmodules-strict-decluse 
-fmodules -fimplicit-module-maps -I %S/Inputs %s 2>&1 | FileCheck %s 
-check-prefix=DECLUSE


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


r284899 - Module: correctly set the module file kind when emitting file_modified.

2016-10-21 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Oct 21 18:35:03 2016
New Revision: 284899

URL: http://llvm.org/viewvc/llvm-project?rev=284899&view=rev
Log:
Module: correctly set the module file kind when emitting file_modified.

rdar://28503343

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

Added:
cfe/trunk/test/Modules/module-file-modified.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=284899&r1=284898&r2=284899&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Oct 21 
18:35:03 2016
@@ -21,6 +21,12 @@ def err_fe_pch_malformed_block : Error<
 def err_fe_pch_file_modified : Error<
 "file '%0' has been modified since the precompiled header '%1' was built">,
 DefaultFatal;
+def err_fe_module_file_modified : Error<
+"file '%0' has been modified since the module file '%1' was built">,
+DefaultFatal;
+def err_fe_ast_file_modified : Error<
+"file '%0' has been modified since the AST file '%1' was built">,
+DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
 def note_pch_required_by : Note<"'%0' required by '%1'">;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=284899&r1=284898&r2=284899&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Oct 21 18:35:03 2016
@@ -1983,6 +1983,7 @@ ASTReader::readInputFileInfo(ModuleFile
   return R;
 }
 
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // If this ID is bogus, just return an empty input file.
   if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@ InputFile ASTReader::getInputFile(Module
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  unsigned DiagnosticKind = 
moduleKindForDiagnostic(ImportStack.back()->Kind);
+  if (DiagnosticKind == 0)
+Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  else if (DiagnosticKind == 1)
+Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+  else
+Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
 
   // Print the import stack.
   if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {

Added: cfe/trunk/test/Modules/module-file-modified.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-file-modified.c?rev=284899&view=auto
==
--- cfe/trunk/test/Modules/module-file-modified.c (added)
+++ cfe/trunk/test/Modules/module-file-modified.c Fri Oct 21 18:35:03 2016
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'int foo = 0;' > %t/a.h
+// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap
+// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap 
-o %t/m.pcm
+// RUN: echo 'int bar;' > %t/a.h
+// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm 
-fmodule-map-file=%t/m.modulemap -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s
+#include "a.h"
+int foo = 0; // redefinition of 'foo'
+// CHECK: fatal error: file {{.*}} has been modified since the module file 
{{.*}} was built
+// REQUIRES: shell


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


[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-10-24 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.

With implicit modules, it is hard to debug issues that depend on state of the 
module cache before the clang invocation. The state of the module cache can be 
changed by other  parallel clang invocations that share the module cache.

We build a module by spawning a child thread. Even when the parent thread 
already validated some modules and stored the FileEntries, the child thread can 
invalidate those modules, causing use-after-free for the parent thread.

Since this issue is time-sensitive, it is hard to reproduce with a release 
compiler. With an assert or an ASAN'ed compiler the chance of reproducing is 
even smaller. This patch tries to diagnose the use-after-free in the compiler, 
by passing up the list of invalidated modules from the child thread and 
emitting a hard error in the parent thread.

Another option is to pass down the list of validated modules from the parent 
thread, the child thread can emit a warning and not invalidate those modules.
I am open to other suggestions as well.


https://reviews.llvm.org/D25916

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Serialization/ModuleManager.h
  lib/Frontend/CompilerInstance.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/Inputs/system-out-of-date/X.h
  test/Modules/Inputs/system-out-of-date/Y.h
  test/Modules/Inputs/system-out-of-date/Z.h
  test/Modules/Inputs/system-out-of-date/module.map
  test/Modules/system-out-of-date-test.m

Index: test/Modules/system-out-of-date-test.m
===
--- test/Modules/system-out-of-date-test.m
+++ test/Modules/system-out-of-date-test.m
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: echo '@import X;' | \
+// RUN:   %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date \
+// RUN: -fsyntax-only -x objective-c -
+
+// We have an version built with different diagnostic options.
+// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module %s -fsyntax-only 2>&1 | FileCheck %s
+
+@import X;
+
+#import 
+// CHECK: fatal error: module 'Y' is invalidated by its child
+// CHECK: fatal error: could not build module 'Z'
Index: test/Modules/Inputs/system-out-of-date/module.map
===
--- test/Modules/Inputs/system-out-of-date/module.map
+++ test/Modules/Inputs/system-out-of-date/module.map
@@ -0,0 +1,12 @@
+module X [system] {
+  header "X.h" // imports Y
+  export *
+}
+module Y {
+  header "Y.h"
+  export *
+}
+module Z {
+  header "Z.h" // imports Y
+  export *
+}
Index: test/Modules/Inputs/system-out-of-date/Z.h
===
--- test/Modules/Inputs/system-out-of-date/Z.h
+++ test/Modules/Inputs/system-out-of-date/Z.h
@@ -0,0 +1 @@
+#import 
Index: test/Modules/Inputs/system-out-of-date/Y.h
===
--- test/Modules/Inputs/system-out-of-date/Y.h
+++ test/Modules/Inputs/system-out-of-date/Y.h
@@ -0,0 +1 @@
+//empty
Index: test/Modules/Inputs/system-out-of-date/X.h
===
--- test/Modules/Inputs/system-out-of-date/X.h
+++ test/Modules/Inputs/system-out-of-date/X.h
@@ -0,0 +1 @@
+#import 
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -182,6 +182,29 @@
   return NewlyLoaded;
 }
 
+// Check to see if the parent thread is holding on to an entry that the child
+// thread invalidated.
+std::string ModuleManager::checkForInvalidateEntries(
+const ModuleMap *modMapInParent, ModuleManager *parentManager) {
+  for (auto E : InvalidatedModules) {
+if (parentManager->lookup(E.first))
+  return E.second;
+
+if (modMapInParent) {
+  if (Module *mod = modMapInParent->findModule(E.second)) {
+if (mod->getASTFile() == E.first)
+  return E.second;
+  }
+}
+  }
+  return "";
+}
+
+void ModuleManager::mergeInvalidatedEntries(ModuleManager *child) {
+  for (auto E : child->InvalidatedModules)
+InvalidatedModules[E.first] = E.second;
+}
+
 void ModuleManager::removeModules(
 ModuleIterator first, ModuleIterator last,
 llvm::SmallPtrSetImpl &LoadedSuccessfully,
@@ -228,8 +251,10 @@
 // Files that didn't make it through ReadASTCore successfully will be
 // rebuilt (or there was an error). Invalidate them so that we can load the
 // new files that will be renamed over the old ones.
-if (LoadedSuccessfully.count(*victim) == 0)
+if (LoadedSuccessfully.count(*victim) == 0) {
+  Inval

[PATCH] D25916: Modules: emit an error instead of a random crash (or a misleading error) due to use-after-free.

2016-10-24 Thread Manman Ren via cfe-commits
manmanren added a comment.

In this testing case, the first clang invocation builds a system module X and a 
non-system module Y (X imports Y). At the second clang invocation, the parent 
thread validates the existing module X and module Y. Because X is a system 
module, we don't diagnose the differences in diagnostic options. When building 
module Z in the child thread, since Z is not a system module, we will spot the 
diagnostic differences and invalidate module Y. But the parent thread will 
continue accessing the deleted FileEntry for module Y.


https://reviews.llvm.org/D25916



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


[PATCH] D25993: [Objective-C] Add objc_subclassing_restricted attribute

2016-10-26 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a reviewer: manmanren.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D25993



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


[PATCH] D26071: [CodeCompletion] Show block invocation result for block property setters

2016-11-08 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D26071



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


[libcxx] r249926 - Revert r249889 due to bot failure.

2015-10-09 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Oct  9 20:03:55 2015
New Revision: 249926

URL: http://llvm.org/viewvc/llvm-project?rev=249926&view=rev
Log:
Revert r249889 due to bot failure.

Removed:
libcxx/trunk/include/wchar.h
Modified:
libcxx/trunk/include/cwchar
libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp

Modified: libcxx/trunk/include/cwchar
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cwchar?rev=249926&r1=249925&r2=249926&view=diff
==
--- libcxx/trunk/include/cwchar (original)
+++ libcxx/trunk/include/cwchar Fri Oct  9 20:03:55 2015
@@ -106,6 +106,9 @@ size_t wcsrtombs(char* restrict dst, con
 #include <__config>
 #include 
 #include 
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#include  // pull in *swprintf defines
+#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -158,13 +161,16 @@ using ::wcscoll;
 using ::wcsncmp;
 using ::wcsxfrm;
 
-#ifdef _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS
+#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
+
 using ::wcschr;
 using ::wcspbrk;
 using ::wcsrchr;
 using ::wcsstr;
 using ::wmemchr;
+
 #else
+
 inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, 
wchar_t __c) {return ::wcschr(__s, __c);}
 inline _LIBCPP_INLINE_VISIBILITY   wchar_t* wcschr(  wchar_t* __s, 
wchar_t __c) {return ::wcschr(__s, __c);}
 
@@ -179,6 +185,7 @@ inline _LIBCPP_INLINE_VISIBILITY   w
 
 inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, 
wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
 inline _LIBCPP_INLINE_VISIBILITY   wchar_t* wmemchr(  wchar_t* __s, 
wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
+
 #endif
 
 using ::wcscspn;

Removed: libcxx/trunk/include/wchar.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/wchar.h?rev=249925&view=auto
==
--- libcxx/trunk/include/wchar.h (original)
+++ libcxx/trunk/include/wchar.h (removed)
@@ -1,136 +0,0 @@
-// -*- C++ -*-
-//===--- wchar.h 
--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#if defined(__need_wint_t) || defined(__need_mbstate_t)
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-#include_next 
-
-#elif !defined(_LIBCPP_WCHAR_H)
-#define _LIBCPP_WCHAR_H
-
-/*
-wchar.h synopsis
-
-Macros:
-
-NULL
-WCHAR_MAX
-WCHAR_MIN
-WEOF
-
-Types:
-
-mbstate_t
-size_t
-tm
-wint_t
-
-int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
-int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
-int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, 
...);
-int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
-int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list 
arg);
-int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list 
arg);  // C99
-int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, 
va_list arg);
-int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, 
va_list arg);  // C99
-int vwprintf(const wchar_t* restrict format, va_list arg);
-int vwscanf(const wchar_t* restrict format, va_list arg);  // C99
-int wprintf(const wchar_t* restrict format, ...);
-int wscanf(const wchar_t* restrict format, ...);
-wint_t fgetwc(FILE* stream);
-wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
-wint_t fputwc(wchar_t c, FILE* stream);
-int fputws(const wchar_t* restrict s, FILE* restrict stream);
-int fwide(FILE* stream, int mode);
-wint_t getwc(FILE* stream);
-wint_t getwchar();
-wint_t putwc(wchar_t c, FILE* stream);
-wint_t putwchar(wchar_t c);
-wint_t ungetwc(wint_t c, FILE* stream);
-double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
-float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); 
// C99
-long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr);  
// C99
-long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
-long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int 
base);  // C99
-unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, 
int base);
-unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict 
endptr, int base);  // C99
-wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
-wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
-wchar_t* wcscat(wchar_t*

Re: [libcxx] r249929 - Split out of .

2015-10-15 Thread Manman Ren via cfe-commits
Hi Richard,

This is causing a failure when building povray on iOS.

Compilation error:
/Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20:
 error: call to 'strrchr' is ambiguous
 const char *p=strrchr(name, '.’);

iOS.sdk/usr/include/string.h:87:7: note: candidate function
char*strrchr(const char *, int);
 ^
/Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46:
 note: candidate function
inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int __c) 
{return ::strrchr(__s, __c);}

It is a little strange to have "char*strrchr(const char *, int);” in iOS. 
But it is already in our SDK.

Do you have any suggestion on how to fix this?

Thanks,
Manman

> On Oct 9, 2015, at 6:25 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Fri Oct  9 20:25:31 2015
> New Revision: 249929
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=249929&view=rev
> Log:
> Split  out of .
> 
> Also fix the overload set for the five functions whose signatures change in 
> the
> case where we can fix it. This is already covered by existing tests for the
> affected systems.
> 
> Added:
>libcxx/trunk/include/string.h
>  - copied, changed from r249736, libcxx/trunk/include/cstring
> Modified:
>libcxx/trunk/include/cstring
> 
> Modified: libcxx/trunk/include/cstring
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff
> ==
> --- libcxx/trunk/include/cstring (original)
> +++ libcxx/trunk/include/cstring Fri Oct  9 20:25:31 2015
> @@ -78,37 +78,42 @@ using ::strcmp;
> using ::strncmp;
> using ::strcoll;
> using ::strxfrm;
> +using ::strcspn;
> +using ::strspn;
> +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
> +using ::strtok;
> +#endif
> +using ::memset;
> +using ::strerror;
> +using ::strlen;
> 
> -using ::memchr;
> +// MSVCRT, GNU libc and its derivates already have the correct prototype in
> +//  if __cplusplus is defined. This macro can be defined by users 
> if
> +// their C library provides the right signature.
> +#if defined(__GLIBC__) || defined(_LIBCPP_MSVCRT) || defined(__sun__) || \
> +defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
> +#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
> +#endif
> 
> +#ifdef _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
> using ::strchr;
> -
> -using ::strcspn;
> -
> using ::strpbrk;
> -
> using ::strrchr;
> -
> -using ::strspn;
> -
> +using ::memchr;
> using ::strstr;
> -
> -// MSVCRT, GNU libc and its derivates already have the correct prototype in 
>  #ifdef __cplusplus
> -#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && 
> !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
> +#else
> +inline _LIBCPP_INLINE_VISIBILITY const char* strchr(const char* __s, int 
> __c) {return ::strchr(__s, __c);}
> inline _LIBCPP_INLINE_VISIBILITY   char* strchr(  char* __s, int __c) 
> {return ::strchr(__s, __c);}
> +inline _LIBCPP_INLINE_VISIBILITY const char* strpbrk(const char* __s1, const 
> char* __s2) {return ::strpbrk(__s1, __s2);}
> inline _LIBCPP_INLINE_VISIBILITY   char* strpbrk(  char* __s1, const 
> char* __s2) {return ::strpbrk(__s1, __s2);}
> +inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int 
> __c) {return ::strrchr(__s, __c);}
> inline _LIBCPP_INLINE_VISIBILITY   char* strrchr(  char* __s, int 
> __c) {return ::strrchr(__s, __c);}
> +inline _LIBCPP_INLINE_VISIBILITY const void* memchr(const void* __s, int 
> __c, size_t __n) {return ::memchr(__s, __c, __n);}
> inline _LIBCPP_INLINE_VISIBILITY   void* memchr(  void* __s, int __c, 
> size_t __n) {return ::memchr(__s, __c, __n);}
> +inline _LIBCPP_INLINE_VISIBILITY const char* strstr(const char* __s1, const 
> char* __s2) {return ::strstr(__s1, __s2);}
> inline _LIBCPP_INLINE_VISIBILITY   char* strstr(  char* __s1, const 
> char* __s2) {return ::strstr(__s1, __s2);}
> #endif
> 
> -#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
> -using ::strtok;
> -#endif
> -using ::memset;
> -using ::strerror;
> -using ::strlen;
> -
> _LIBCPP_END_NAMESPACE_STD
> 
> #endif  // _LIBCPP_CSTRING
> 
> Copied: libcxx/trunk/include/string.h (from r249736, 
> libcxx/trunk/include/cstring)
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string.h?p2=libcxx/trunk/include/string.h&p1=libcxx/trunk/include/cstring&r1=249736&r2=249929&rev=249929&view=diff
> ==
> --- libcxx/trunk/include/cstring (original)
> +++ libcxx/trunk/include/string.h Fri Oct  9 20:25:31 2015
> @@ -1,5 +1,5 @@
> // -*- C++ -*-
> -//===--- cstring 
> --===//
> +//===--- string.h 
> --

Re: [libcxx] r249929 - Split out of .

2015-10-15 Thread Manman Ren via cfe-commits

> On Oct 15, 2015, at 11:25 AM, Richard Smith  wrote:
> 
> I assume the code in question has a "using namespace std;"?
> 
> 
Yes

> I don't see any way around this other than giving up on trying to fix the 
> function signatures here (or maybe adding a Clang feature to let us fix the 
> bad signature).
> 
> 
Can you elaborate on how to fix the bad signature by adding a Clang feature? I 
want to see how hard it is before giving up on trying to fix the signatures.

Thanks,
Manman


> On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Hi Richard,
> 
> This is causing a failure when building povray on iOS.
> 
> Compilation error:
> /Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20:
>  error: call to 'strrchr' is ambiguous
>  const char *p=strrchr(name, '.’);
> 
> iOS.sdk/usr/include/string.h:87:7: note: candidate function
> char*strrchr(const char *, int);
>  ^
> /Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46:
>  note: candidate function
> inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int 
> __c) {return ::strrchr(__s, __c);}
> 
> It is a little strange to have "char*strrchr(const char *, int);” in iOS. 
> But it is already in our SDK.
> 
> Do you have any suggestion on how to fix this?
> 
> Thanks,
> Manman
> 
> > On Oct 9, 2015, at 6:25 PM, Richard Smith via cfe-commits 
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> >
> > Author: rsmith
> > Date: Fri Oct  9 20:25:31 2015
> > New Revision: 249929
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=249929&view=rev 
> > <http://llvm.org/viewvc/llvm-project?rev=249929&view=rev>
> > Log:
> > Split  out of .
> >
> > Also fix the overload set for the five functions whose signatures change in 
> > the
> > case where we can fix it. This is already covered by existing tests for the
> > affected systems.
> >
> > Added:
> >libcxx/trunk/include/string.h
> >  - copied, changed from r249736, libcxx/trunk/include/cstring
> > Modified:
> >libcxx/trunk/include/cstring
> >
> > Modified: libcxx/trunk/include/cstring
> > URL: 
> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff
> >  
> > <http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff>
> > ==
> > --- libcxx/trunk/include/cstring (original)
> > +++ libcxx/trunk/include/cstring Fri Oct  9 20:25:31 2015
> > @@ -78,37 +78,42 @@ using ::strcmp;
> > using ::strncmp;
> > using ::strcoll;
> > using ::strxfrm;
> > +using ::strcspn;
> > +using ::strspn;
> > +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
> > +using ::strtok;
> > +#endif
> > +using ::memset;
> > +using ::strerror;
> > +using ::strlen;
> >
> > -using ::memchr;
> > +// MSVCRT, GNU libc and its derivates already have the correct prototype in
> > +//  if __cplusplus is defined. This macro can be defined by 
> > users if
> > +// their C library provides the right signature.
> > +#if defined(__GLIBC__) || defined(_LIBCPP_MSVCRT) || defined(__sun__) || \
> > +defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
> > +#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
> > +#endif
> >
> > +#ifdef _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
> > using ::strchr;
> > -
> > -using ::strcspn;
> > -
> > using ::strpbrk;
> > -
> > using ::strrchr;
> > -
> > -using ::strspn;
> > -
> > +using ::memchr;
> > using ::strstr;
> > -
> > -// MSVCRT, GNU libc and its derivates already have the correct prototype 
> > in  #ifdef __cplusplus
> > -#if !defined(__GLIBC__) && !defined(_LIBCPP_MSVCRT) && !defined(__sun__) 
> > && !defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
> > +#else
> > +inline _LIBCPP_INLINE_VISIBILITY const char* strchr(const char* __s, int 
> > __c) {return ::strchr(__s, __c);}
> > inline _LIBCPP_INLINE_VISIBILITY   char* strchr(  char* __s, int 
> > __c) {return ::strchr(__s, __c);}
> > +inline _LIBCPP_INLINE_VISIBILITY const char* strpbrk(const char* __s1, 
> > const char* __s2) {return ::strpbrk(__s1, __s2);}
> > inline _LIBCPP_INLI

Re: [libcxx] r249929 - Split out of .

2015-10-15 Thread Manman Ren via cfe-commits

> On Oct 15, 2015, at 1:41 PM, Richard Smith  wrote:
> 
> On Thu, Oct 15, 2015 at 12:03 PM, Manman Ren via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
>> On Oct 15, 2015, at 11:25 AM, Richard Smith > <mailto:rich...@metafoo.co.uk>> wrote:
>> 
>> I assume the code in question has a "using namespace std;"?
>> 
>> 
> Yes
> 
>> I don't see any way around this other than giving up on trying to fix the 
>> function signatures here (or maybe adding a Clang feature to let us fix the 
>> bad signature).
>> 
>> 
> Can you elaborate on how to fix the bad signature by adding a Clang feature? 
> I want to see how hard it is before giving up on trying to fix the signatures.
> 
> I thought about this a bit more, and we already have a feature that can be 
> used for this.
> 
> Please let me know if the attached patch resolves the issue for you. This 
> should also fix the wrong overload sets for these functions being provided by 
>  on Darwin.

This works on my testing case. Thanks!!

Manman

> 
> 
> Eric, Marshall: the attached patch adds a macro _LIBCPP_PREFERRED_OVERLOAD 
> that can be applied to a function to (a) mark it as a separate overload from 
> any other function with the same signature without the overload, and (b) 
> instruct the compiler that it's preferred over another function with the same 
> signature without the attribute. This allows us to replace the libc function
> 
>   char *strchr(const char *, int);
> 
> with the C++ overload set:
> 
>   const char *strchr(const char *, int);
>   char *strchr(char *, int);
> 
> It only works with Clang, though; for other compilers, we leave the C 
> library's signature alone (as we used to before my patches landed).
> 
> Thanks,
> Manman
> 
> 
>> On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Hi Richard,
>> 
>> This is causing a failure when building povray on iOS.
>> 
>> Compilation error:
>> /Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20:
>>  error: call to 'strrchr' is ambiguous
>>  const char *p=strrchr(name, '.’);
>> 
>> iOS.sdk/usr/include/string.h:87:7: note: candidate function
>> char*strrchr(const char *, int);
>>  ^
>> /Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46:
>>  note: candidate function
>> inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int 
>> __c) {return ::strrchr(__s, __c);}
>> 
>> It is a little strange to have "char*strrchr(const char *, int);” in 
>> iOS. But it is already in our SDK.
>> 
>> Do you have any suggestion on how to fix this?
>> 
>> Thanks,
>> Manman
>> 
>> > On Oct 9, 2015, at 6:25 PM, Richard Smith via cfe-commits 
>> > mailto:cfe-commits@lists.llvm.org>> wrote:
>> >
>> > Author: rsmith
>> > Date: Fri Oct  9 20:25:31 2015
>> > New Revision: 249929
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=249929&view=rev 
>> > <http://llvm.org/viewvc/llvm-project?rev=249929&view=rev>
>> > Log:
>> > Split  out of .
>> >
>> > Also fix the overload set for the five functions whose signatures change 
>> > in the
>> > case where we can fix it. This is already covered by existing tests for the
>> > affected systems.
>> >
>> > Added:
>> >libcxx/trunk/include/string.h
>> >  - copied, changed from r249736, libcxx/trunk/include/cstring
>> > Modified:
>> >libcxx/trunk/include/cstring
>> >
>> > Modified: libcxx/trunk/include/cstring
>> > URL: 
>> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff
>> >  
>> > <http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff>
>> > ==
>> > --- libcxx/trunk/include/cstring (original)
>> > +++ libcxx/trunk/include/cstring Fri Oct  9 20:25:31 2015
>> > @@ -78,37 +78,42 @@ using ::strcmp;
>> > using ::strncmp;
>> > using ::strcoll;
>> > using ::strxfrm;
>> > +using ::strcspn;
>> > +using ::strspn;
>> > +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_

Stage 2 bot failure: clang-stage2-configure-Rlto_check

2015-10-16 Thread Manman Ren via cfe-commits
There are 33 commits picked up in this run and we have 107 test failures. This 
happened at 2pm today.

I wonder if any one knows what is going on.

http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/6222/
 
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/6222/changes

Test Result (107 failures / +107)
• Clang.Analysis.CheckNSError.m
• Clang.Analysis.DynamicTypePropagation.m
• Clang.Analysis.NSContainers.m
• Clang.Analysis.NSString.m
• Clang.Analysis.NewDelete-checker-test.cpp
• Clang.Analysis.PR24184.cpp
• Clang.Analysis.PR2599.m
• Clang.Analysis.additive-folding-range-constraints.c
• Clang.Analysis.additive-folding.cpp
• Clang.Analysis.array-struct-region.cpp

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


Re: [clang-tools-extra] r250939 - [clang-tidy] add check cppcoreguidelines-pro-type-vararg

2015-10-21 Thread Manman Ren via cfe-commits
It seems that this commit breaks the following bot
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/12461/ 


Manman

> On Oct 21, 2015, at 1:09 PM, Matthias Gehre via cfe-commits 
>  wrote:
> 
> Author: mgehre
> Date: Wed Oct 21 15:09:02 2015
> New Revision: 250939
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=250939&view=rev
> Log:
> [clang-tidy] add check cppcoreguidelines-pro-type-vararg
> 
> Summary:
> This check flags all calls to c-style vararg functions and all use
> of va_list, va_start and va_arg.
> 
> Passing to varargs assumes the correct type will be read. This is
> fragile because it cannot generally be enforced to be safe in the
> language and so relies on programmer discipline to get it right.
> 
> This rule is part of the "Type safety" profile of the C++ Core
> Guidelines, see
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type8-avoid-reading-from-varargs-or-passing-vararg-arguments-prefer-variadic-template-parameters-instead
> 
> This commits also reverts
>  "[clang-tidy] add cert's VariadicFunctionDefCheck as 
> cppcoreguidelines-pro-type-vararg-def"
> because that check makes the SFINAE use of vararg functions impossible.
> 
> Reviewers: alexfh, sbenza, bkramer, aaron.ballman
> 
> Subscribers: cfe-commits
> 
> Differential Revision: http://reviews.llvm.org/D13787
> 
> Added:
>clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
>clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.rst
>
> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp
> Modified:
>clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
>
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
>clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
> 
> Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=250939&r1=250938&r2=250939&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Wed 
> Oct 21 15:09:02 2015
> @@ -7,6 +7,7 @@ add_clang_library(clangTidyCppCoreGuidel
>   ProTypeReinterpretCastCheck.cpp
>   ProTypeStaticCastDowncastCheck.cpp
>   ProTypeUnionAccessCheck.cpp
> +  ProTypeVarargCheck.cpp
> 
>   LINK_LIBS
>   clangAST
> @@ -14,7 +15,6 @@ add_clang_library(clangTidyCppCoreGuidel
>   clangBasic
>   clangLex
>   clangTidy
> -  clangTidyCERTModule
>   clangTidyMiscModule
>   clangTidyUtils
>   clangTooling
> 
> Modified: 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=250939&r1=250938&r2=250939&view=diff
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
>  (original)
> +++ 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
>  Wed Oct 21 15:09:02 2015
> @@ -10,13 +10,13 @@
> #include "../ClangTidy.h"
> #include "../ClangTidyModule.h"
> #include "../ClangTidyModuleRegistry.h"
> -#include "../cert/VariadicFunctionDefCheck.h"
> #include "../misc/AssignOperatorSignatureCheck.h"
> #include "ProBoundsPointerArithmeticCheck.h"
> #include "ProTypeConstCastCheck.h"
> #include "ProTypeReinterpretCastCheck.h"
> #include "ProTypeStaticCastDowncastCheck.h"
> #include "ProTypeUnionAccessCheck.h"
> +#include "ProTypeVarargCheck.h"
> 
> namespace clang {
> namespace tidy {
> @@ -30,14 +30,14 @@ public:
> "cppcoreguidelines-pro-bounds-pointer-arithmetic");
> CheckFactories.registerCheck(
> "cppcoreguidelines-pro-type-const-cast");
> -CheckFactories.registerCheck(
> -"cppcoreguidelines-pro-type-vararg-def");
> CheckFactories.registerCheck(
> "cppcoreguidelines-pro-type-reinterpret-cast");
> CheckFactories.registerCheck(
> "cppcoreguidelines-pro-type-static-cast-downcast");
> CheckFactories.registerCheck(
> "cppcoreguidelines-pro-type-union-access");
> +CheckFactories.registerCheck(
> +"cppcoreguidelines-pro-type-vararg");
> CheckFactories.registerCheck(
> "cppcoreguidelines-c-copy-assignment-signature");
>   }
> 
> Added: 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp

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

2015-11-03 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.
manmanren added a comment.

Inliner currently does not include analysis passes such as BPI and BFI. With 
the new pass manager, we should be able to hook up inliner with BFI (and we can 
handle throw in BFI). Before that, maybe we can add this as part of inlining 
analysis?


http://reviews.llvm.org/D13304



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


r252777 - [TLS] move setting tls_guard in tls_init.

2015-11-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Nov 11 13:19:26 2015
New Revision: 252777

URL: http://llvm.org/viewvc/llvm-project?rev=252777&view=rev
Log:
[TLS] move setting tls_guard in tls_init.

We used to emit the store prior to branch in the entry block. To make it more
efficient, this commit moves it to the init block. We still mark as initialized
before initializing anything else.

Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
cfe/trunk/test/OpenMP/threadprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=252777&r1=252776&r2=252777&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Nov 11 13:19:26 2015
@@ -518,14 +518,14 @@ CodeGenFunction::GenerateCXXGlobalInitFu
   llvm::Value *GuardVal = Builder.CreateLoad(Guard);
   llvm::Value *Uninit = Builder.CreateIsNull(GuardVal,
  "guard.uninitialized");
-  // Mark as initialized before initializing anything else. If the
-  // initializers use previously-initialized thread_local vars, that's
-  // probably supposed to be OK, but the standard doesn't say.
-  Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), 
Guard);
   llvm::BasicBlock *InitBlock = createBasicBlock("init");
   ExitBlock = createBasicBlock("exit");
   Builder.CreateCondBr(Uninit, InitBlock, ExitBlock);
   EmitBlock(InitBlock);
+  // Mark as initialized before initializing anything else. If the
+  // initializers use previously-initialized thread_local vars, that's
+  // probably supposed to be OK, but the standard doesn't say.
+  Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), 
Guard);
 }
 
 RunCleanupsScope Scope(*this);

Modified: cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp?rev=252777&r1=252776&r2=252777&view=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp Wed Nov 11 13:19:26 2015
@@ -173,9 +173,9 @@ void set_anon_i() {
 // CHECK: define {{.*}}@__tls_init()
 // CHECK: load i8, i8* @__tls_guard
 // CHECK: %[[NEED_TLS_INIT:.*]] = icmp eq i8 %{{.*}}, 0
-// CHECK: store i8 1, i8* @__tls_guard
 // CHECK: br i1 %[[NEED_TLS_INIT]],
 // init:
+// CHECK: store i8 1, i8* @__tls_guard
 // CHECK: call void @[[A_INIT]]()
 // CHECK: call void @[[D_INIT]]()
 // CHECK: call void @[[U_M_INIT]]()

Modified: cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/threadprivate_codegen.cpp?rev=252777&r1=252776&r2=252777&view=diff
==
--- cfe/trunk/test/OpenMP/threadprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/threadprivate_codegen.cpp Wed Nov 11 13:19:26 2015
@@ -939,9 +939,9 @@ int foobar() {
 // CHECK-TLS:  define internal void @__tls_init()
 // CHECK-TLS:  [[GRD:%.*]] = load i8, i8* @__tls_guard
 // CHECK-TLS-NEXT: [[IS_INIT:%.*]] = icmp eq i8 [[GRD]], 0
-// CHECK-TLS-NEXT: store i8 1, i8* @__tls_guard
 // CHECK-TLS-NEXT: br i1 [[IS_INIT]], label %[[INIT_LABEL:[^,]+]], label 
%[[DONE_LABEL:[^,]+]]{{.*}}
 // CHECK-TLS:  [[INIT_LABEL]]
+// CHECK-TLS-NEXT: store i8 1, i8* @__tls_guard
 // CHECK-TLS:  call void [[GS1_CXX_INIT]]
 // CHECK-TLS-NOT:  call void [[GS2_CXX_INIT]]
 // CHECK-TLS:  call void [[ARR_X_CXX_INIT]]


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


r252814 - [TLS on Darwin] change how we handle globals with linkonce or weak linkage.

2015-11-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Nov 11 16:42:31 2015
New Revision: 252814

URL: http://llvm.org/viewvc/llvm-project?rev=252814&view=rev
Log:
[TLS on Darwin] change how we handle globals with linkonce or weak linkage.

This is about how we handle static member of a template. Before this commit,
we use internal linkage for the IR thread-local variable, which is inefficient.
With this commit, we will start to follow Itanium C++ ABI.

rdar://problem/23415206

Reviewed by John McCall.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx11-thread-local-reference.cpp
cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
cfe/trunk/test/CodeGenCXX/tls-init-funcs.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=252814&r1=252813&r2=252814&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Nov 11 16:42:31 2015
@@ -2315,12 +2315,17 @@ void CodeGenModule::EmitGlobalVarDefinit
   llvm::GlobalValue::LinkageTypes Linkage =
   getLLVMLinkageVarDefinition(D, GV->isConstant());
 
-  // On Darwin, the backing variable for a C++11 thread_local variable always
-  // has internal linkage; all accesses should just be calls to the
+  // On Darwin, if the normal linkage of a C++ thread_local variable is
+  // LinkOnce or Weak, we keep the normal linkage to prevent multiple
+  // copies within a linkage unit; otherwise, the backing variable has
+  // internal linkage and all accesses should just be calls to the
   // Itanium-specified entry point, which has the normal linkage of the
-  // variable.
+  // variable. This is to preserve the ability to change the implementation
+  // behind the scenes.
   if (!D->isStaticLocal() && D->getTLSKind() == VarDecl::TLS_Dynamic &&
-  Context.getTargetInfo().getTriple().isMacOSX())
+  Context.getTargetInfo().getTriple().isMacOSX() &&
+  !llvm::GlobalVariable::isLinkOnceLinkage(Linkage) &&
+  !llvm::GlobalVariable::isWeakLinkage(Linkage))
 Linkage = llvm::GlobalValue::InternalLinkage;
 
   GV->setLinkage(Linkage);

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=252814&r1=252813&r2=252814&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Nov 11 16:42:31 2015
@@ -2163,12 +2163,10 @@ getThreadLocalWrapperLinkage(const VarDe
 return VarLinkage;
 
   // If the thread wrapper is replaceable, give it appropriate linkage.
-  if (isThreadWrapperReplaceable(VD, CGM)) {
-if (llvm::GlobalVariable::isLinkOnceLinkage(VarLinkage) ||
-llvm::GlobalVariable::isWeakODRLinkage(VarLinkage))
-  return llvm::GlobalVariable::WeakAnyLinkage;
-return VarLinkage;
-  }
+  if (isThreadWrapperReplaceable(VD, CGM))
+if (!llvm::GlobalVariable::isLinkOnceLinkage(VarLinkage) &&
+!llvm::GlobalVariable::isWeakODRLinkage(VarLinkage))
+  return VarLinkage;
   return llvm::GlobalValue::WeakODRLinkage;
 }
 
@@ -2194,7 +2192,9 @@ ItaniumCXXABI::getOrCreateThreadLocalWra
   llvm::Function::Create(FnTy, getThreadLocalWrapperLinkage(VD, CGM),
  WrapperName.str(), &CGM.getModule());
   // Always resolve references to the wrapper at link time.
-  if (!Wrapper->hasLocalLinkage() && !isThreadWrapperReplaceable(VD, CGM))
+  if (!Wrapper->hasLocalLinkage() && !(isThreadWrapperReplaceable(VD, CGM) &&
+  !llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) &&
+  !llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage(
 Wrapper->setVisibility(llvm::GlobalValue::HiddenVisibility);
   return Wrapper;
 }

Modified: cfe/trunk/test/CodeGenCXX/cxx11-thread-local-reference.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-thread-local-reference.cpp?rev=252814&r1=252813&r2=252814&view=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx11-thread-local-reference.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local-reference.cpp Wed Nov 11 
16:42:31 2015
@@ -1,11 +1,14 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-apple-darwin12 
| FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
 
 int &f();
 
-// CHECK: @r = thread_local global i32* null
+// LINUX: @r = thread_local global i32* null
+// DARWIN: @r = internal thread_local global i32* null
 thread_local in

r252820 - [TLS on Darwin] treat all Darwin platforms in the same way.

2015-11-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Nov 11 17:08:18 2015
New Revision: 252820

URL: http://llvm.org/viewvc/llvm-project?rev=252820&view=rev
Log:
[TLS on Darwin] treat all Darwin platforms in the same way.

rdar://problem/9001553

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=252820&r1=252819&r2=252820&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Nov 11 17:08:18 2015
@@ -2323,7 +2323,7 @@ void CodeGenModule::EmitGlobalVarDefinit
   // variable. This is to preserve the ability to change the implementation
   // behind the scenes.
   if (!D->isStaticLocal() && D->getTLSKind() == VarDecl::TLS_Dynamic &&
-  Context.getTargetInfo().getTriple().isMacOSX() &&
+  Context.getTargetInfo().getTriple().isOSDarwin() &&
   !llvm::GlobalVariable::isLinkOnceLinkage(Linkage) &&
   !llvm::GlobalVariable::isWeakLinkage(Linkage))
 Linkage = llvm::GlobalValue::InternalLinkage;

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=252820&r1=252819&r2=252820&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Nov 11 17:08:18 2015
@@ -2088,7 +2088,7 @@ static void emitGlobalDtorWithCXAAtExit(
   const char *Name = "__cxa_atexit";
   if (TLS) {
 const llvm::Triple &T = CGF.getTarget().getTriple();
-Name = T.isMacOSX() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
   }
 
   // We're assuming that the destructor function is something we can
@@ -2144,10 +2144,10 @@ void ItaniumCXXABI::registerGlobalDtor(C
 static bool isThreadWrapperReplaceable(const VarDecl *VD,
CodeGen::CodeGenModule &CGM) {
   assert(!VD->isStaticLocal() && "static local VarDecls don't need wrappers!");
-  // OS X prefers to have references to thread local variables to go through
+  // Darwin prefers to have references to thread local variables to go through
   // the thread wrapper instead of directly referencing the backing variable.
   return VD->getTLSKind() == VarDecl::TLS_Dynamic &&
- CGM.getTarget().getTriple().isMacOSX();
+ CGM.getTarget().getTriple().isOSDarwin();
 }
 
 /// Get the appropriate linkage for the wrapper function. This is essentially


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


Re: [PATCH] D22183: [SemObjC] Fix TypoExpr handling in TransformObjCDictionaryLiteral

2016-07-18 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman



Comment at: lib/Parse/ParseObjc.cpp:3489
@@ -3478,3 +3488,3 @@
 
-// Parse the ellipsis that designates this as a pack expansion.
-SourceLocation EllipsisLoc;
+// Check the key and value for possible typos
+KeyExpr = Actions.CorrectDelayedTyposInExpr(KeyExpr.get());

Add a period at the end of the comment.


https://reviews.llvm.org/D22183



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


[PATCH] D22636: Module: retry building modules that were just compiled by the same instance and are are out of date

2016-07-21 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.

Even though this instance just built module "A", it is likely that "A" imports 
another module "B" and B.pcm becomes out of date when we try to load module 
"A", because another instance overwrites "B.pcm" due to changes in warning 
options. This patch tries to fix the error: "Module file ‘.pcm' 
is out of date and needs to be rebuilt" by simply trying again.

This seems to be the last case where we call ReadAST without the ability to 
handle out-of-date.

If there are other ways to fix the issue, please let me know.
Also I don't quite know how to add a testing case when two compiling instances 
are involved and running in parallel.

rdar://problem/26676111

https://reviews.llvm.org/D22636

Files:
  lib/Frontend/CompilerInstance.cpp

Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -1096,6 +1096,7 @@
 diagnoseBuildFailure();
 return false;
   }
+  ModuleLoadCapabilities |= ASTReader::ARR_OutOfDate;
   break;
 
 case llvm::LockFileManager::LFS_Shared:
@@ -1124,10 +1125,14 @@
 ModuleLoadCapabilities);
 
 if (ReadResult == ASTReader::OutOfDate &&
-Locked == llvm::LockFileManager::LFS_Shared) {
+(Locked == llvm::LockFileManager::LFS_Shared ||
+ Locked == llvm::LockFileManager::LFS_Owned)) {
   // The module may be out of date in the presence of file system races,
   // or if one of its imports depends on header search paths that are not
   // consistent with this ImportingInstance.  Try again...
+
+  // The module may be out of date right after we rebuild it if a module
+  // it imports is overwritten by another process. Try again...
   continue;
 } else if (ReadResult == ASTReader::Missing) {
   diagnoseBuildFailure();


Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -1096,6 +1096,7 @@
 diagnoseBuildFailure();
 return false;
   }
+  ModuleLoadCapabilities |= ASTReader::ARR_OutOfDate;
   break;
 
 case llvm::LockFileManager::LFS_Shared:
@@ -1124,10 +1125,14 @@
 ModuleLoadCapabilities);
 
 if (ReadResult == ASTReader::OutOfDate &&
-Locked == llvm::LockFileManager::LFS_Shared) {
+(Locked == llvm::LockFileManager::LFS_Shared ||
+ Locked == llvm::LockFileManager::LFS_Owned)) {
   // The module may be out of date in the presence of file system races,
   // or if one of its imports depends on header search paths that are not
   // consistent with this ImportingInstance.  Try again...
+
+  // The module may be out of date right after we rebuild it if a module
+  // it imports is overwritten by another process. Try again...
   continue;
 } else if (ReadResult == ASTReader::Missing) {
   diagnoseBuildFailure();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-07-21 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.

This is a patch I applied internally to debug out-of-date issues. In general is 
this the right way to add debugging messages in clang frontend?


https://reviews.llvm.org/D22638

Files:
  lib/Frontend/CompilerInstance.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ModuleManager.cpp

Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -16,6 +16,7 @@
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "clang/Serialization/ModuleManager.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
@@ -25,6 +26,8 @@
 #include "llvm/Support/GraphWriter.h"
 #endif
 
+#define DEBUG_TYPE "module-manager"
+
 using namespace clang;
 using namespace serialization;
 
@@ -76,6 +79,8 @@
   }
   if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) {
 ErrorStr = "module file out of date";
+DEBUG(llvm::dbgs() << "In addModule: size or modtime mismatch "
+   << FileName << '\n';);
 return OutOfDate;
   }
 
@@ -169,6 +174,8 @@
   assert(ImportedBy);
 delete ModuleEntry;
   }
+  DEBUG(llvm::dbgs() << "In addModule: signature mismatch "
+ << FileName << '\n';);
   return OutOfDate;
 }
   }
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -51,6 +51,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Bitcode/BitstreamWriter.h"
 #include "llvm/Support/Compression.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -62,6 +63,8 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "module-astwriter"
+
 using namespace clang;
 using namespace clang::serialization;
 
@@ -4113,6 +4116,7 @@
 uint64_t ASTWriter::WriteAST(Sema &SemaRef, const std::string &OutputFile,
  Module *WritingModule, StringRef isysroot,
  bool hasErrors) {
+  DEBUG(llvm::dbgs() << "In WriteAST: " << OutputFile << '\n';);
   WritingAST = true;
 
   ASTHasCompilerErrors = hasErrors;
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -49,6 +49,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/Support/Compression.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -60,6 +61,8 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "module-astreader"
+
 using namespace clang;
 using namespace clang::serialization;
 using namespace clang::serialization::reader;
@@ -364,6 +367,8 @@
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror=" +
   Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str();
+DEBUG(llvm::dbgs() << "In checkDiagnosticGroupMappings: DiagID "
+   << Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str() << '\n';);
 return true;
   }
 }
@@ -390,27 +395,39 @@
 if (StoredDiags.getSuppressSystemWarnings()) {
   if (Complain)
 Diags.Report(diag::err_pch_diagopt_mismatch) << "-Wsystem-headers";
+  DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: suppress system warnings"
+ << ": IsSystem "
+ << IsSystem << '\n';);
   return true;
 }
   }
 
   if (Diags.getWarningsAsErrors() && !StoredDiags.getWarningsAsErrors()) {
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror";
+DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: warnings as errors"
+   << ": IsSystem "
+   << IsSystem << '\n';);
 return true;
   }
 
   if (Diags.getWarningsAsErrors() && Diags.getEnableAllWarnings() &&
   !StoredDiags.getEnableAllWarnings()) {
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-Weverything -Werror";
+DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: enable all warnings"
+   << ": IsSystem "
+   << IsSystem << '\n';);
 return true;
   }
 
   if (isExtHandlingFromDiagsError(Diags) &&
   !isExtHandlingFromDiagsError(StoredDiags)) {
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-pedantic-errors";
+D

Re: [PATCH] D22636: Module: retry building modules that were just compiled by the same instance and are are out of date

2016-07-21 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D22636#491679, @benlangmuir wrote:

> > B.pcm becomes out of date when we try to load module "A", because another 
> > instance overwrites "B.pcm"
>
>
> How can this happen?  We intentionally keep the file descriptors of modules 
> open.  If you just built A, then you will have B.pcm still open.  When you 
> read A, you will use the same B that you used when you built A even if the 
> file on disk has been replaced (and we use rename to replace the file, so the 
> existing one is never modified).


Can you point me to the source codes where we use rename to replace the file? I 
am curious on how this all works out.

What I described is a scenario I thought possible that can cause "out-of-date" 
error:
module "B" is out of date and needs to be rebuilt
note: imported by module "A"

The only invocation of ReadAST that reads a module file and can't handle 
out-of-date modules, is the path where we just built module "A" and tries to 
load module "A" (here ModuleLoadCapabilities will be ARR_Missing).

I am still working with the project owner to collect more debugging messages.

If this is not a possible scenario, do you have any suggestion on what can 
cause this error?

Cheers,
Manman


https://reviews.llvm.org/D22636



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


Re: [PATCH] D22542: [CodeGen] Fix a crash on valid when constant folding 'default:' statement in switch

2016-07-21 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


https://reviews.llvm.org/D22542



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


Re: [PATCH] D22636: Module: retry building modules that were just compiled by the same instance and are are out of date

2016-07-22 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D22636#493072, @benlangmuir wrote:

> > Can you point me to the source codes where we use rename to replace the 
> > file? I am curious on how this all works out.
>
>
> This is the same as clang's handling of other output files.  See 
> {{CompilerInstance::createOutputFile}} and {{clearOutputFiles}}.  When we are 
> performing the GenerateModuleAction, the .pcm file will be the output file.


Thanks for the info!

> 

> 

> > What I described is a scenario I thought possible that can cause 
> > "out-of-date" error:

> 

> >  module "B" is out of date and needs to be rebuilt

> 

> >  note: imported by module "A"

> 

> >  The only invocation of ReadAST that reads a module file and can't handle 
> > out-of-date modules, is the path where we just built module "A" and tries 
> > to load module "A" (here ModuleLoadCapabilities will be ARR_Missing).

> 

> 

> Right, here and in PCH loading (I assume your case doesn't involve a PCH).  
> I'm concerned about adding this loop, because it removes the guarantee of 
> progress.  We should never need to build a module more than once in the same 
> compilation.  If we have a bug that's causing us to not be able to load a 
> module that we just compiled, I think we need to fix the underlying problem, 
> not just retry the build.


Yes, I agree. We should try to figure out the root cause. I gave the project 
owner a root with debugging messages, but with this root, the error disappeared 
:(

If you have suggestions on debugging this, let me know.

Thanks,
Manman


https://reviews.llvm.org/D22636



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


[PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added a reviewer: benlangmuir.
manmanren added a subscriber: cfe-commits.

With PCH+Module, sometimes compiler gives a hard error:
"Module file ‘.pcm' is out of date and needs to be rebuilt"

This happens when we have a PCH importing a module and the module gets 
overwritten by another compiler instance after we build the pch (one example is 
that both compiler instances hash to the same pcm file but use different 
diagnostic options). When we try to load the pch later on, the compiler notices 
that the imported module is out of date (modification date, size do not match)  
but it can't handle this out of date pcm (i.e it does not know how to rebuild 
the pch).

This patch introduces a new command line option so for PCH + module, we can 
turn on this option and if two compiler instances only differ in diagnostic 
options, the latter instance will not invalidate the original pcm.


https://reviews.llvm.org/D22773

Files:
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/Driver/modules.m
  test/Modules/Inputs/DiagOutOfDate.h
  test/Modules/Inputs/module.map
  test/Modules/Inputs/pch-import-module-out-of-date.pch
  test/Modules/diagnostic-options-out-of-date.m

Index: test/Modules/diagnostic-options-out-of-date.m
===
--- test/Modules/diagnostic-options-out-of-date.m
+++ test/Modules/diagnostic-options-out-of-date.m
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s
+// RUN: %clang_cc1 -Werror -Wno-conversion -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-out-of-date.pch
+// RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify -fmodules-disable-diagnostic-validation
+// expected-no-diagnostics
+
+@import DiagOutOfDate;
Index: test/Modules/Inputs/pch-import-module-out-of-date.pch
===
--- test/Modules/Inputs/pch-import-module-out-of-date.pch
+++ test/Modules/Inputs/pch-import-module-out-of-date.pch
@@ -0,0 +1 @@
+@import DiagOutOfDate;
Index: test/Modules/Inputs/module.map
===
--- test/Modules/Inputs/module.map
+++ test/Modules/Inputs/module.map
@@ -418,3 +418,7 @@
 module MacroFabs1 {
   header "MacroFabs1.h"
 }
+
+module DiagOutOfDate {
+  header "DiagOutOfDate.h"
+}
Index: test/Modules/Inputs/DiagOutOfDate.h
===
--- test/Modules/Inputs/DiagOutOfDate.h
+++ test/Modules/Inputs/DiagOutOfDate.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -33,6 +33,12 @@
 // RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
+// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: -fmodules-disable-diagnostic-validation
+
+// RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2084,7 +2084,7 @@
 ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
 BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
 bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
-std::string &SuggestedPredefines) {
+std::string &SuggestedPredefines, bool ValidateDiagnosticOptions) {
   if (Stream.EnterSubBlock(OPTIONS_BLOCK_ID))
 return Failure;
 
@@ -2128,7 +2128,8 @@
 
 case DIAGNOSTIC_OPTIONS: {
   bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
-  if (!AllowCompatibleConfigurationMismatch &&
+  if (ValidateDiagno

Re: [PATCH] D22697: [ObjC Availability] Consider lexical context of use of declaration when emitting availability diagnostics

2016-07-25 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM except one nit.

Manman



Comment at: include/clang/Sema/Sema.h:9595
@@ -9594,1 +9594,3 @@
+
+  VersionTuple getCurContextVersion() const;
   

Can you add comments here?


https://reviews.llvm.org/D22697



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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D22773#495403, @benlangmuir wrote:

> We need to add this option to the module hash (see getModuleHash - we already 
> add a bunch of other HSOpts there).  Otherwise the pcm could still be 
> rewritten by a compilation that doesn't use a PCH, and then it would be out 
> of date because of the timestamp instead of the diagnostic options.


I was thinking that for a project using PCH+Module, all clang invocations will 
be using -fmodules-disable-diagnostic-validation, so if only the diagnostic 
options change, they will hash to the same pcm file but the compiler will not 
regenerate and overwrite the existing pcm file. So when we load the pch, the 
time stamp etc will match and the compiler will not throw out-of-date error.

We can definitely hash the option HSOpts.ModulesValidateDiagnosticOptions in 
getModuleHash. But I don't quite get the reason you give here :)
the pcm could still be rewritten by a compilation that doesn't use a PCH, and 
then it would be out of date because of the timestamp instead of the diagnostic 
options

"a compilation that doesn't use a PCH", is that a different project? And we 
have two projects building in parallel? Just to make sure I understand.

Thanks!
Manman


https://reviews.llvm.org/D22773



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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D22773#495524, @benlangmuir wrote:

> > the pcm could still be rewritten by a compilation that doesn't use a PCH, 
> > and then it would be out of date because of the timestamp instead of the 
> > diagnostic options
>
> > 
>
> > "a compilation that doesn't use a PCH", is that a different project? And we 
> > have two projects building in parallel? Just to make sure I understand.
>
>
> Two different projects (or targets, or whatever), but they don't even have to 
> build at the same time.  They just have to share a cache. Suppose you have a 
> project A with a PCH and -fmodules-disable-diagnostic-validation.  Suppose 
> you have another project B that does not use this flag, and does not have a 
> PCH.  With this patch, A and B can share a module cache.
>
> A builds a PCH that depends on some module X -- OK
>  B builds with -Werror.  Rebuilds X.pcm -- OK
>
> Now suppose we build A again because of some change:  it can't build because 
> X.pcm changed, but we haven't rebuilt the PCH.


Got it, I will update the patch!

Manman


https://reviews.llvm.org/D22773



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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 65449.
manmanren added a comment.

Addressing Ben's comments


https://reviews.llvm.org/D22773

Files:
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/Driver/modules.m
  test/Modules/Inputs/DiagOutOfDate.h
  test/Modules/Inputs/module.map
  test/Modules/Inputs/pch-import-module-out-of-date.pch
  test/Modules/diagnostic-options-out-of-date.m

Index: test/Modules/diagnostic-options-out-of-date.m
===
--- test/Modules/diagnostic-options-out-of-date.m
+++ test/Modules/diagnostic-options-out-of-date.m
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// Build A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
+// Build pch that imports A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-out-of-date.pch -fmodules-disable-diagnostic-validation
+// Make sure that we don't rebuild A.pcm and overwrite the original A.pcm that the pch imports
+// RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
+// Make sure we don't error out when using the pch
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify -fmodules-disable-diagnostic-validation
+// expected-no-diagnostics
+
+@import DiagOutOfDate;
Index: test/Modules/Inputs/pch-import-module-out-of-date.pch
===
--- test/Modules/Inputs/pch-import-module-out-of-date.pch
+++ test/Modules/Inputs/pch-import-module-out-of-date.pch
@@ -0,0 +1 @@
+@import DiagOutOfDate;
Index: test/Modules/Inputs/module.map
===
--- test/Modules/Inputs/module.map
+++ test/Modules/Inputs/module.map
@@ -418,3 +418,7 @@
 module MacroFabs1 {
   header "MacroFabs1.h"
 }
+
+module DiagOutOfDate {
+  header "DiagOutOfDate.h"
+}
Index: test/Modules/Inputs/DiagOutOfDate.h
===
--- test/Modules/Inputs/DiagOutOfDate.h
+++ test/Modules/Inputs/DiagOutOfDate.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -33,6 +33,12 @@
 // RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
+// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: -fmodules-disable-diagnostic-validation
+
+// RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2084,7 +2084,7 @@
 ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
 BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
 bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
-std::string &SuggestedPredefines) {
+std::string &SuggestedPredefines, bool ValidateDiagnosticOptions) {
   if (Stream.EnterSubBlock(OPTIONS_BLOCK_ID))
 return Failure;
 
@@ -2128,7 +2128,8 @@
 
 case DIAGNOSTIC_OPTIONS: {
   bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
-  if (!AllowCompatibleConfigurationMismatch &&
+  if (ValidateDiagnosticOptions &&
+  !AllowCompatibleConfigurationMismatch &&
   ParseDiagnosticOptions(Record, Complain, Listener))
 return OutOfDate;
   break;
@@ -2255,10 +2256,13 @@
   // FIXME: Allow this for files explicitly specified with -include-pch.
   bool AllowCompatibleConfigurationMismatch =
   F.Kind == MK_ExplicitModule;
+  const HeaderSearchOptions &HSOpts =
+  PP.getHeaderSearchInfo().getHeaderSearchOpts();
 
   Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,

r276769 - Modules: add command line option fmodules-disable-diagnostic-validation

2016-07-26 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Jul 26 12:12:17 2016
New Revision: 276769

URL: http://llvm.org/viewvc/llvm-project?rev=276769&view=rev
Log:
Modules: add command line option fmodules-disable-diagnostic-validation

With PCH+Module, sometimes compiler gives a hard error:
Module file ‘.pcm' is out of date and needs to be rebuilt

This happens when we have a pch importing a module and the module gets
overwritten by another compiler instance after we build the pch (one example is
that both compiler instances hash to the same pcm file but use different
diagnostic options). When we try to load the pch later on, the compiler notices
that the imported module is out of date (modification date, size do not match)
but it can't handle this out of date pcm (i.e it does not know how to rebuild
the pch).

This commit introduces a new command line option so for PCH + module, we can
turn on this option and if two compiler instances only differ in diagnostic
options, the latter instance will not invalidate the original pcm.

rdar://26675801
Differential Revision: http://reviews.llvm.org/D22773

Added:
cfe/trunk/test/Modules/Inputs/DiagOutOfDate.h
cfe/trunk/test/Modules/Inputs/pch-import-module-out-of-date.pch
cfe/trunk/test/Modules/diagnostic-options-out-of-date.m
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Driver/modules.m
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276769&r1=276768&r2=276769&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Jul 26 12:12:17 2016
@@ -857,6 +857,9 @@ def fmodules_validate_once_per_build_ses
   Group, Flags<[CC1Option]>,
   HelpText<"Don't verify input files for the modules if the module has been "
"successfully validated or loaded during this build session">;
+def fmodules_disable_diagnostic_validation : Flag<["-"], 
"fmodules-disable-diagnostic-validation">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Disable validation of the diagnostic options when loading the 
module">;
 def fmodules_validate_system_headers : Flag<["-"], 
"fmodules-validate-system-headers">,
   Group, Flags<[CC1Option]>,
   HelpText<"Validate the system headers that a module depends on when loading 
the module">;

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=276769&r1=276768&r2=276769&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Tue Jul 26 12:12:17 2016
@@ -172,6 +172,8 @@ public:
   /// Whether the module includes debug information (-gmodules).
   unsigned UseDebugInfo : 1;
 
+  unsigned ModulesValidateDiagnosticOptions : 1;
+
   HeaderSearchOptions(StringRef _Sysroot = "/")
   : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(0),
 ImplicitModuleMaps(0), ModuleMapFileHomeIsCwd(0),
@@ -181,7 +183,7 @@ public:
 UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false),
-UseDebugInfo(false) {}
+UseDebugInfo(false), ModulesValidateDiagnosticOptions(true) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
   void AddPath(StringRef Path, frontend::IncludeDirGroup Group,

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=276769&r1=276768&r2=276769&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Jul 26 12:12:17 2016
@@ -1153,7 +1153,7 @@ private:
   static ASTReadResult ReadOptionsBlock(
   llvm::BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
   bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
-  std::string &SuggestedPredefines);
+  std::string &SuggestedPredefines, bool ValidateDiagnosticOptions);
   ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);
   ASTReadResult ReadExtensionBlock(ModuleFile &F);
   bool ParseLineTable(ModuleFile &F, const RecordData &Record);
@@ -1516,7 +1516,8 @@ public:
   readASTFileControlBlock(StringRef Filename, FileManager &FileMgr,
   

r276797 - Modules: follow up to r276769.

2016-07-26 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Jul 26 14:56:12 2016
New Revision: 276797

URL: http://llvm.org/viewvc/llvm-project?rev=276797&view=rev
Log:
Modules: follow up to r276769.

In r276769, I forgot to forward the driver option, add that here.

rdar://26675801

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276797&r1=276796&r2=276797&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jul 26 14:56:12 2016
@@ -5443,6 +5443,7 @@ void Clang::ConstructJob(Compilation &C,
   }
 
   Args.AddLastArg(CmdArgs, options::OPT_fmodules_validate_system_headers);
+  Args.AddLastArg(CmdArgs, 
options::OPT_fmodules_disable_diagnostic_validation);
 
   // -faccess-control is default.
   if (Args.hasFlag(options::OPT_fno_access_control,


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


Re: [PATCH] D22636: Module: retry building modules that were just compiled by the same instance and are are out of date

2016-07-27 Thread Manman Ren via cfe-commits
manmanren abandoned this revision.
manmanren added a comment.

Abandon this change for now.


https://reviews.llvm.org/D22636



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


  1   2   3   >