]> granicus.if.org Git - clang/commitdiff
Disable access control by default. It can be enabled with the -faccess-control option...
authorAnders Carlsson <andersca@mac.com>
Wed, 13 May 2009 19:49:53 +0000 (19:49 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 13 May 2009 19:49:53 +0000 (19:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71706 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticFrontendKinds.td
include/clang/Basic/LangOptions.h
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHWriter.cpp
lib/Sema/SemaAccess.cpp
test/SemaCXX/access-base-class.cpp
test/SemaCXX/conditional-expr.cpp
tools/clang-cc/clang-cc.cpp

index 94ec2a5a16af04d1ad3e19d1a33060bbabdc0051..1bc296babd3bf2e47f4e305797e46718602bddf4 100644 (file)
@@ -127,6 +127,10 @@ def warn_macro_name_used_in_pch : Error<
 def warn_pch_compiler_options_mismatch : Error<
     "compiler options used when building the precompiled header differ from "
     "the options used when using the precompiled header">;
+def warn_pch_access_control : Error<
+    "C++ access control was %select{disabled|enabled}0 in the PCH file but "
+    "is currently %select{disabled|enabled}1">;
+
 def err_not_a_pch_file : Error<
     "'%0' does not appear to be a precompiled header file">, DefaultFatal;
 }
index fba474b2f527759bcd4765a19966024ce7caca09..1214afacd0ef50c5efc0853f6b4a982c776dbd59 100644 (file)
@@ -75,6 +75,8 @@ public:
   unsigned ObjCGCBitmapPrint : 1; // Enable printing of gc's bitmap layout
                                   // for __weak/__strong ivars.
 
+  unsigned AccessControl     : 1; // Whether C++ access control should 
+                                  // be enabled.
 private:
   unsigned GC : 2; // Objective-C Garbage Collection modes.  We declare
                    // this enum as unsigned because MSVC insists on making enums
@@ -115,6 +117,9 @@ public:
     EmitAllDecls = 0;
     MathErrno = 1;
 
+    // FIXME: The default should be 1.
+    AccessControl = 0;
+    
     OverflowChecking = 0;
     ObjCGCBitmapPrint = 0;
 
index ab7ad04e9d97345953e164998017b79cde742190..25415bb368eaa7b7876a2e645f87b757dc901fd3 100644 (file)
@@ -1520,6 +1520,7 @@ bool PCHReader::ParseLanguageOptions(
   PARSE_LANGOPT_IMPORTANT(PICLevel, diag::warn_pch_pic_level);
   PARSE_LANGOPT_IMPORTANT(GNUInline, diag::warn_pch_gnu_inline);
   PARSE_LANGOPT_IMPORTANT(NoInline, diag::warn_pch_no_inline);
+  PARSE_LANGOPT_IMPORTANT(AccessControl, diag::warn_pch_access_control);
   if ((LangOpts.getGCMode() != 0) != (Record[Idx] != 0)) {
     Diag(diag::warn_pch_gc_mode) 
       << (unsigned)Record[Idx] << LangOpts.getGCMode();
index e05a73568f4ec0683f476289ea053e04e4e04e3c..883825418e79eb9faab15c89c1e2d934ac7c9a9d 100644 (file)
@@ -546,6 +546,8 @@ void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
   Record.push_back(LangOpts.GNUInline); // Should GNU inline semantics be
                                   // used (instead of C99 semantics).
   Record.push_back(LangOpts.NoInline); // Should __NO_INLINE__ be defined.
+  Record.push_back(LangOpts.AccessControl); // Whether C++ access control should
+                                            // be enabled.
   Record.push_back(LangOpts.getGCMode());
   Record.push_back(LangOpts.getVisibilityMode());
   Record.push_back(LangOpts.InstantiationDepth);
index cc212434b794252a7cdbbb24d9914f0eaf684eca..b832d38d1d8b5e9f01cbd4ac6deb51d0fcd941da 100644 (file)
@@ -53,6 +53,9 @@ bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
   assert(Paths.isRecordingPaths() &&
          "Can't check base class access without recorded paths");
   
+  if (!getLangOptions().AccessControl)
+    return false;
+  
   const CXXBaseSpecifier *InacessibleBase = 0;
 
   const CXXRecordDecl* CurrentClassDecl = 0;
index f98437695efe342f31a28e25f38a15b97fa90c5f..4a9ee51dbfb5bfb7b296b98752216d06e6299b3c 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -faccess-control -verify %s
 namespace T1 {
   
 class A { };
index 3fede303b64f6b90f7ef84873a20fd9a2673997f..3f4d7159a0f8f0b36476d10a92a4ce797d2d1de1 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s
+// RUN: clang-cc -fsyntax-only -verify -faccess-control -std=c++0x %s
 
 // C++ rules for ?: are a lot stricter than C rules, and have to take into
 // account more conversion options.
index 9fa0d79e691bdcf86af9f99a507c63862463460c..a7f65902d8fe89cf6a5fbb6390b9318918651169 100644 (file)
@@ -669,6 +669,11 @@ static llvm::cl::opt<std::string>
 MainFileName("main-file-name",
              llvm::cl::desc("Main file name to use for debug info"));
 
+// FIXME: Also add an "-fno-access-control" option.
+static llvm::cl::opt<bool>
+AccessControl("faccess-control", 
+              llvm::cl::desc("Enable C++ access control"));
+
 // It might be nice to add bounds to the CommandLine library directly.
 struct OptLevelParser : public llvm::cl::parser<unsigned> {
   bool parse(llvm::cl::Option &O, const char *ArgName,
@@ -801,6 +806,9 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
   if (EnableHeinousExtensions)
     Options.HeinousExtensions = 1;
 
+  if (AccessControl)
+    Options.AccessControl = 1;
+  
   Options.MathErrno = MathErrno;
 
   Options.InstantiationDepth = TemplateDepth;