r262789 - [Modules] Don't swallow errors when parsing optional attributes.

Davide Italiano via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 5 20:20:05 PST 2016


Author: davide
Date: Sat Mar  5 22:20:05 2016
New Revision: 262789

URL: http://llvm.org/viewvc/llvm-project?rev=262789&view=rev
Log:
[Modules] Don't swallow errors when parsing optional attributes.

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

Added:
    cfe/trunk/test/Modules/parse-attributes.modulemap
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=262789&r1=262788&r2=262789&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Sat Mar  5 22:20:05 2016
@@ -1402,7 +1402,9 @@ void ModuleMapParser::parseModuleDecl()
   
   // Parse the optional attribute list.
   Attributes Attrs;
-  parseOptionalAttributes(Attrs);
+  if (parseOptionalAttributes(Attrs))
+    return;
+
   
   // Parse the opening brace.
   if (!Tok.is(MMToken::LBrace)) {
@@ -2067,7 +2069,9 @@ void ModuleMapParser::parseConfigMacros(
 
   // Parse the optional attributes.
   Attributes Attrs;
-  parseOptionalAttributes(Attrs);
+  if (parseOptionalAttributes(Attrs))
+    return;
+
   if (Attrs.IsExhaustive && !ActiveModule->Parent) {
     ActiveModule->ConfigMacrosExhaustive = true;
   }
@@ -2215,7 +2219,8 @@ void ModuleMapParser::parseInferredModul
 
   // Parse optional attributes.
   Attributes Attrs;
-  parseOptionalAttributes(Attrs);
+  if (parseOptionalAttributes(Attrs))
+    return;
 
   if (ActiveModule) {
     // Note that we have an inferred submodule.

Added: cfe/trunk/test/Modules/parse-attributes.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/parse-attributes.modulemap?rev=262789&view=auto
==============================================================================
--- cfe/trunk/test/Modules/parse-attributes.modulemap (added)
+++ cfe/trunk/test/Modules/parse-attributes.modulemap Sat Mar  5 22:20:05 2016
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t.modules
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t.modules \
+// RUN:   -fmodule-map-file=%s -I%S -include "Inputs/empty.h" \
+// RUN:   -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s
+
+// CHECK: error: expected ']' to close attribute
+// CHECK-NOT: error: expected '{' to start module 'A'
+
+module A [system {
+  header "Inputs/empty.h"
+  private header "Inputs/empty.h"
+}




More information about the cfe-commits mailing list